<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span id="local-6989586621681112857"></span><span class="hs-pragma">{-# LANGUAGE RecordWildCards #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ExistentialQuantification #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Errors.Hole</span><span>
</span><span id="line-5"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#findValidHoleFits"><span class="hs-identifier">findValidHoleFits</span></a></span><span>
</span><span id="line-6"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier">tcCheckHoleFit</span></a></span><span>
</span><span id="line-7"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#withoutUnification"><span class="hs-identifier">withoutUnification</span></a></span><span>
</span><span id="line-8"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcSubsumes"><span class="hs-identifier">tcSubsumes</span></a></span><span>
</span><span id="line-9"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier">isFlexiTyVar</span></a></span><span>
</span><span id="line-10"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier">tcFilterHoleFits</span></a></span><span>
</span><span id="line-11"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getLocalBindings"><span class="hs-identifier">getLocalBindings</span></a></span><span>
</span><span id="line-12"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier">pprHoleFit</span></a></span><span>
</span><span id="line-13"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#addHoleFitDocs"><span class="hs-identifier">addHoleFitDocs</span></a></span><span>
</span><span id="line-14"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getHoleFitSortingAlg"><span class="hs-identifier">getHoleFitSortingAlg</span></a></span><span>
</span><span id="line-15"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getHoleFitDispConfig"><span class="hs-identifier">getHoleFitDispConfig</span></a></span><span>
</span><span id="line-16"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitDispConfig"><span class="hs-identifier">HoleFitDispConfig</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitSortingAlg"><span class="hs-identifier">HoleFitSortingAlg</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#relevantCts"><span class="hs-identifier">relevantCts</span></a></span><span>
</span><span id="line-19"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#zonkSubs"><span class="hs-identifier">zonkSubs</span></a></span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsByGraph"><span class="hs-identifier">sortHoleFitsByGraph</span></a></span><span>
</span><span id="line-22"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsBySize"><span class="hs-identifier">sortHoleFitsBySize</span></a></span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>   </span><span class="hs-comment">-- Re-exported from GHC.Tc.Errors.Hole.FitTypes</span><span>
</span><span id="line-26"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFitPlugin"><span class="hs-identifier">HoleFitPlugin</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFitPluginR"><span class="hs-identifier">HoleFitPluginR</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span>   </span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">where</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html"><span class="hs-identifier">GHC.Tc.Types</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#pprNameProvenance"><span class="hs-identifier">pprNameProvenance</span></a></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier">GlobalRdrElt</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#globalRdrEnvElts"><span class="hs-identifier">globalRdrEnvElts</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html#gHC_ERR"><span class="hs-identifier">gHC_ERR</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier">ConLike</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier">tcLookup</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html"><span class="hs-identifier">GHC.Utils.FV</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier">fvVarList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier">fvVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#unionFV"><span class="hs-identifier">unionFV</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-identifier">mkFVs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier">FV</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#%26%26%26"><span class="hs-operator">(&amp;&amp;&amp;)</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#filterM"><span class="hs-identifier">filterM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#replicateM"><span class="hs-identifier">replicateM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier">foldM</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier">partition</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier">sort</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sortOn"><span class="hs-identifier">sortOn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#nubBy"><span class="hs-identifier">nubBy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#"><span class="hs-identifier">Data.Graph</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#graphFromEdges"><span class="hs-identifier">graphFromEdges</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#topSort"><span class="hs-identifier">topSort</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html"><span class="hs-identifier">GHC.Tc.Solver</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier">simpl_top</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#runTcSDeriveds"><span class="hs-identifier">runTcSDeriveds</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier">tcSubTypeSigma</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Docs.html"><span class="hs-identifier">GHC.HsToCore.Docs</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.HsToCore.Docs.html#extractDocs"><span class="hs-identifier">extractDocs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.html#"><span class="hs-identifier">Data.Map</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Map</span></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.Doc.html"><span class="hs-identifier">GHC.Hs.Doc</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Hs.Doc.html#unpackHDS"><span class="hs-identifier">unpackHDS</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Doc.html#DeclDocMap"><span class="hs-identifier">DeclDocMap</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModIface_"><span class="hs-identifier">ModIface_</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html"><span class="hs-identifier">GHC.Iface.Load</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html#loadInterfaceForNameMaybe"><span class="hs-identifier">loadInterfaceForNameMaybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Utils.html"><span class="hs-identifier">GHC.Builtin.Utils</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Builtin.Utils.html#knownKeyNames"><span class="hs-identifier">knownKeyNames</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html"><span class="hs-identifier">GHC.Tc.Errors.Hole.FitTypes</span></a></span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-comment">{-
Note [Valid hole fits include ...]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`findValidHoleFits` returns the &quot;Valid hole fits include ...&quot; message.
For example, look at the following definitions in a file called test.hs:

   import Data.List (inits)

   f :: [String]
   f = _ &quot;hello, world&quot;

The hole in `f` would generate the message:

  &#8226; Found hole: _ :: [Char] -&gt; [String]
  &#8226; In the expression: _
    In the expression: _ &quot;hello, world&quot;
    In an equation for &#8216;f&#8217;: f = _ &quot;hello, world&quot;
  &#8226; Relevant bindings include f :: [String] (bound at test.hs:6:1)
    Valid hole fits include
      lines :: String -&gt; [String]
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;base-4.11.0.0:Data.OldList&#8217;))
      words :: String -&gt; [String]
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;base-4.11.0.0:Data.OldList&#8217;))
      inits :: forall a. [a] -&gt; [[a]]
        with inits @Char
        (imported from &#8216;Data.List&#8217; at mpt.hs:4:19-23
          (and originally defined in &#8216;base-4.11.0.0:Data.OldList&#8217;))
      repeat :: forall a. a -&gt; [a]
        with repeat @String
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;GHC.List&#8217;))
      fail :: forall (m :: * -&gt; *). Monad m =&gt; forall a. String -&gt; m a
        with fail @[] @String
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;GHC.Base&#8217;))
      return :: forall (m :: * -&gt; *). Monad m =&gt; forall a. a -&gt; m a
        with return @[] @String
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;GHC.Base&#8217;))
      pure :: forall (f :: * -&gt; *). Applicative f =&gt; forall a. a -&gt; f a
        with pure @[] @String
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;GHC.Base&#8217;))
      read :: forall a. Read a =&gt; String -&gt; a
        with read @[String]
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;Text.Read&#8217;))
      mempty :: forall a. Monoid a =&gt; a
        with mempty @([Char] -&gt; [String])
        (imported from &#8216;Prelude&#8217; at mpt.hs:3:8-9
          (and originally defined in &#8216;GHC.Base&#8217;))

Valid hole fits are found by checking top level identifiers and local bindings
in scope for whether their type can be instantiated to the type of the hole.
Additionally, we also need to check whether all relevant constraints are solved
by choosing an identifier of that type as well, see Note [Relevant constraints]

Since checking for subsumption results in the side-effect of type variables
being unified by the simplifier, we need to take care to restore them after
to being flexible type variables after we've checked for subsumption.
This is to avoid affecting the hole and later checks by prematurely having
unified one of the free unification variables.

When outputting, we sort the hole fits by the size of the types we'd need to
apply by type application to the type of the fit to make it fit. This is done
in order to display &quot;more relevant&quot; suggestions first. Another option is to
sort by building a subsumption graph of fits, i.e. a graph of which fits subsume
what other fits, and then outputting those fits which are subsumed by other
fits (i.e. those more specific than other fits) first. This results in the ones
&quot;closest&quot; to the type of the hole to be displayed first.

To help users understand how the suggested fit works, we also display the values
that the quantified type variables would take if that fit is used, like
`mempty @([Char] -&gt; [String])` and `pure @[] @String` in the example above.
If -XTypeApplications is enabled, this can even be copied verbatim as a
replacement for the hole.

Note [Checking hole fits]
~~~~~~~~~~~~~~~~~~~~~~~~~
If we have a hole of type hole_ty, we want to know whether a variable
of type ty is a valid fit for the whole. This is a subsumption check:
we wish to know whether ty &lt;: hole_ty. But, of course, the check
must take into account any givens and relevant constraints.
(See also Note [Relevant constraints]).

For the simplifier to be able to use any givens present in the enclosing
implications to solve relevant constraints, we nest the wanted subsumption
constraints and relevant constraints within the enclosing implications.

As an example, let's look at the following code:

  f :: Show a =&gt; a -&gt; String
  f x = show _

Suppose the hole is assigned type a0_a1pd[tau:2].
Here the nested implications are just one level deep, namely:

  [Implic {
      TcLevel = 2
      Skolems = a_a1pa[sk:2]
      No-eqs = True
      Status = Unsolved
      Given = $dShow_a1pc :: Show a_a1pa[sk:2]
      Wanted =
        WC {wc_simple =
              [WD] $dShow_a1pe {0}:: Show a0_a1pd[tau:2] (CDictCan(psc))}
      Binds = EvBindsVar&lt;a1pi&gt;
      Needed inner = []
      Needed outer = []
      the type signature for:
        f :: forall a. Show a =&gt; a -&gt; String }]

As we can see, the givens say that the skolem
`a_a1pa[sk:2]` fulfills the Show constraint, and that we must prove
the [W] Show a0_a1pd[tau:2] constraint -- that is, whatever fills the
hole must have a Show instance.

When we now check whether `x :: a_a1pa[sk:2]` fits the hole in
`tcCheckHoleFit`, the call to `tcSubType` will end up unifying the meta type
variable `a0_a1pd[tau:2] := a_a1pa[sk:2]`. By wrapping the wanted constraints
needed by tcSubType_NC and the relevant constraints (see Note [Relevant
Constraints] for more details) in the nested implications, we can pass the
information in the givens along to the simplifier. For our example, we end up
needing to check whether the following constraints are soluble.

  WC {wc_impl =
        Implic {
          TcLevel = 2
          Skolems = a_a1pa[sk:2]
          No-eqs = True
          Status = Unsolved
          Given = $dShow_a1pc :: Show a_a1pa[sk:2]
          Wanted =
            WC {wc_simple =
                  [WD] $dShow_a1pe {0}:: Show a0_a1pd[tau:2] (CNonCanonical)}
          Binds = EvBindsVar&lt;a1pl&gt;
          Needed inner = []
          Needed outer = []
          the type signature for:
            f :: forall a. Show a =&gt; a -&gt; String }}

But since `a0_a1pd[tau:2] := a_a1pa[sk:2]` and we have from the nested
implications that Show a_a1pa[sk:2] is a given, this is trivial, and we end up
with a final WC of WC {}, confirming x :: a0_a1pd[tau:2] as a match.

To avoid side-effects on the nested implications, we create a new EvBindsVar so
that any changes to the ev binds during a check remains localised to that check.
In addition, we call withoutUnification to reset any unified metavariables; this
call is actually done outside tcCheckHoleFit so that the results can be formatted
for the user before resetting variables.

Note [Valid refinement hole fits include ...]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When the `-frefinement-level-hole-fits=N` flag is given, we additionally look
for &quot;valid refinement hole fits&quot;&quot;, i.e. valid hole fits with up to N
additional holes in them.

With `-frefinement-level-hole-fits=0` (the default), GHC will find all
identifiers 'f' (top-level or nested) that will fit in the hole.

With `-frefinement-level-hole-fits=1`, GHC will additionally find all
applications 'f _' that will fit in the hole, where 'f' is an in-scope
identifier, applied to single argument.  It will also report the type of the
needed argument (a new hole).

And similarly as the number of arguments increases

As an example, let's look at the following code:

  f :: [Integer] -&gt; Integer
  f = _

with `-frefinement-level-hole-fits=1`, we'd get:

  Valid refinement hole fits include

    foldl1 (_ :: Integer -&gt; Integer -&gt; Integer)
      with foldl1 @[] @Integer
      where foldl1 :: forall (t :: * -&gt; *).
                      Foldable t =&gt;
                      forall a. (a -&gt; a -&gt; a) -&gt; t a -&gt; a
    foldr1 (_ :: Integer -&gt; Integer -&gt; Integer)
      with foldr1 @[] @Integer
      where foldr1 :: forall (t :: * -&gt; *).
                      Foldable t =&gt;
                      forall a. (a -&gt; a -&gt; a) -&gt; t a -&gt; a
    const (_ :: Integer)
      with const @Integer @[Integer]
      where const :: forall a b. a -&gt; b -&gt; a
    ($) (_ :: [Integer] -&gt; Integer)
      with ($) @'GHC.Types.LiftedRep @[Integer] @Integer
      where ($) :: forall a b. (a -&gt; b) -&gt; a -&gt; b
    fail (_ :: String)
      with fail @((-&gt;) [Integer]) @Integer
      where fail :: forall (m :: * -&gt; *).
                    Monad m =&gt;
                    forall a. String -&gt; m a
    return (_ :: Integer)
      with return @((-&gt;) [Integer]) @Integer
      where return :: forall (m :: * -&gt; *). Monad m =&gt; forall a. a -&gt; m a
    (Some refinement hole fits suppressed;
      use -fmax-refinement-hole-fits=N or -fno-max-refinement-hole-fits)

Which are hole fits with holes in them. This allows e.g. beginners to
discover the fold functions and similar, but also allows for advanced users
to figure out the valid functions in the Free monad, e.g.

  instance Functor f =&gt; Monad (Free f) where
      Pure a &gt;&gt;= f = f a
      Free f &gt;&gt;= g = Free (fmap _a f)

Will output (with -frefinment-level-hole-fits=1):
    Found hole: _a :: Free f a -&gt; Free f b
          Where: &#8216;a&#8217;, &#8216;b&#8217; are rigid type variables bound by
                  the type signature for:
                    (&gt;&gt;=) :: forall a b. Free f a -&gt; (a -&gt; Free f b) -&gt; Free f b
                  at fms.hs:25:12-14
                &#8216;f&#8217; is a rigid type variable bound by
    ...
    Relevant bindings include
      g :: a -&gt; Free f b (bound at fms.hs:27:16)
      f :: f (Free f a) (bound at fms.hs:27:10)
      (&gt;&gt;=) :: Free f a -&gt; (a -&gt; Free f b) -&gt; Free f b
        (bound at fms.hs:25:12)
    ...
    Valid refinement hole fits include
      ...
      (=&lt;&lt;) (_ :: a -&gt; Free f b)
        with (=&lt;&lt;) @(Free f) @a @b
        where (=&lt;&lt;) :: forall (m :: * -&gt; *) a b.
                      Monad m =&gt;
                      (a -&gt; m b) -&gt; m a -&gt; m b
        (imported from &#8216;Prelude&#8217; at fms.hs:5:18-22
        (and originally defined in &#8216;GHC.Base&#8217;))
      ...

Where `(=&lt;&lt;) _` is precisely the function we want (we ultimately want `&gt;&gt;= g`).

We find these refinement suggestions by considering hole fits that don't
fit the type of the hole, but ones that would fit if given an additional
argument. We do this by creating a new type variable with `newOpenFlexiTyVar`
(e.g. `t_a1/m[tau:1]`), and then considering hole fits of the type
`t_a1/m[tau:1] -&gt; v` where `v` is the type of the hole.

Since the simplifier is free to unify this new type variable with any type, we
can discover any identifiers that would fit if given another identifier of a
suitable type. This is then generalized so that we can consider any number of
additional arguments by setting the `-frefinement-level-hole-fits` flag to any
number, and then considering hole fits like e.g. `foldl _ _` with two additional
arguments.

To make sure that the refinement hole fits are useful, we check that the types
of the additional holes have a concrete value and not just an invented type
variable. This eliminates suggestions such as `head (_ :: [t0 -&gt; a]) (_ :: t0)`,
and limits the number of less than useful refinement hole fits.

Additionally, to further aid the user in their implementation, we show the
types of the holes the binding would have to be applied to in order to work.
In the free monad example above, this is demonstrated with
`(=&lt;&lt;) (_ :: a -&gt; Free f b)`, which tells the user that the `(=&lt;&lt;)` needs to
be applied to an expression of type `a -&gt; Free f b` in order to match.
If -XScopedTypeVariables is enabled, this hole fit can even be copied verbatim.

Note [Relevant constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
As highlighted by #14273, we need to check any relevant constraints as well
as checking for subsumption. Relevant constraints are the simple constraints
whose free unification variables are mentioned in the type of the hole.

In the simplest case, these are all non-hole constraints in the simples, such
as is the case in

  f :: String
  f = show _

Here, the hole is given type a0_a1kv[tau:1]. Then, the emitted constraint is:

  [WD] $dShow_a1kw {0}:: Show a0_a1kv[tau:1] (CNonCanonical)

However, when there are multiple holes, we need to be more careful. As an
example, Let's take a look at the following code:

  f :: Show a =&gt; a -&gt; String
  f x = show (_b (show _a))

Here there are two holes, `_a` and `_b`. Suppose _a :: a0_a1pd[tau:2] and
_b :: a1_a1po[tau:2]. Then, the simple constraints passed to
findValidHoleFits are:

  [[WD] $dShow_a1pe {0}:: Show a0_a1pd[tau:2] (CNonCanonical),
    [WD] $dShow_a1pp {0}:: Show a1_a1po[tau:2] (CNonCanonical)]

When we are looking for a match for the hole `_a`, we filter the simple
constraints to the &quot;Relevant constraints&quot;, by throwing out any constraints
which do not mention a variable mentioned in the type of the hole. For hole
`_a`, we will then only require that the `$dShow_a1pe` constraint is solved,
since that is the only constraint that mentions any free type variables
mentioned in the hole constraint for `_a`, namely `a_a1pd[tau:2]`, and
similarly for the hole `_b` we only require that the `$dShow_a1pe` constraint
is solved.

Note [Leaking errors]
~~~~~~~~~~~~~~~~~~~~~
When considering candidates, GHC believes that we're checking for validity in
actual source. However, As evidenced by #15321, #15007 and #15202, this can
cause bewildering error messages. The solution here is simple: if a candidate
would cause the type checker to error, it is not a valid hole fit, and thus it
is discarded.

-}</span><span>
</span><span id="line-389"></span><span>
</span><span id="line-390"></span><span class="hs-keyword">data</span><span> </span><span id="HoleFitDispConfig"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitDispConfig"><span class="hs-identifier hs-var">HoleFitDispConfig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="HFDC"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HFDC"><span class="hs-identifier hs-var">HFDC</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="showWrap"><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.html#showWrap"><span class="hs-identifier hs-var hs-var">showWrap</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-391"></span><span>                              </span><span class="hs-special">,</span><span> </span><span id="showWrapVars"><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.html#showWrapVars"><span class="hs-identifier hs-var hs-var">showWrapVars</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-392"></span><span>                              </span><span class="hs-special">,</span><span> </span><span id="showType"><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.html#showType"><span class="hs-identifier hs-var hs-var">showType</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-393"></span><span>                              </span><span class="hs-special">,</span><span> </span><span id="showProv"><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.html#showProv"><span class="hs-identifier hs-var hs-var">showProv</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-394"></span><span>                              </span><span class="hs-special">,</span><span> </span><span id="showMatches"><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.html#showMatches"><span class="hs-identifier hs-var hs-var">showMatches</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-395"></span><span>
</span><span id="line-396"></span><span class="hs-comment">-- We read the various -no-show-*-of-hole-fits flags</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- and set the display config accordingly.</span><span>
</span><span id="line-398"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getHoleFitDispConfig"><span class="hs-identifier hs-type">getHoleFitDispConfig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitDispConfig"><span class="hs-identifier hs-type">HoleFitDispConfig</span></a></span><span>
</span><span id="line-399"></span><span id="getHoleFitDispConfig"><span class="annot"><span class="annottext">getHoleFitDispConfig :: TcM HoleFitDispConfig
</span><a href="GHC.Tc.Errors.Hole.html#getHoleFitDispConfig"><span class="hs-identifier hs-var hs-var">getHoleFitDispConfig</span></a></span></span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112609"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112609"><span class="hs-identifier hs-var">sWrap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowTypeAppOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowTypeAppOfHoleFits</span></a></span><span>
</span><span id="line-401"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112606"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112606"><span class="hs-identifier hs-var">sWrapVars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowTypeAppVarsOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowTypeAppVarsOfHoleFits</span></a></span><span>
</span><span id="line-402"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112604"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112604"><span class="hs-identifier hs-var">sType</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowTypeOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowTypeOfHoleFits</span></a></span><span>
</span><span id="line-403"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112602"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112602"><span class="hs-identifier hs-var">sProv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowProvOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowProvOfHoleFits</span></a></span><span>
</span><span id="line-404"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112600"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112600"><span class="hs-identifier hs-var">sMatc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowMatchesOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowMatchesOfHoleFits</span></a></span><span>
</span><span id="line-405"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; TcM HoleFitDispConfig
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HFDC :: Bool -&gt; Bool -&gt; Bool -&gt; Bool -&gt; Bool -&gt; HoleFitDispConfig
</span><a href="GHC.Tc.Errors.Hole.html#HFDC"><span class="hs-identifier hs-type">HFDC</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">showWrap :: Bool
</span><a href="GHC.Tc.Errors.Hole.html#showWrap"><span class="hs-identifier hs-var">showWrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112609"><span class="hs-identifier hs-var">sWrap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">showWrapVars :: Bool
</span><a href="GHC.Tc.Errors.Hole.html#showWrapVars"><span class="hs-identifier hs-var">showWrapVars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112606"><span class="hs-identifier hs-var">sWrapVars</span></a></span><span>
</span><span id="line-406"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">showProv :: Bool
</span><a href="GHC.Tc.Errors.Hole.html#showProv"><span class="hs-identifier hs-var">showProv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112602"><span class="hs-identifier hs-var">sProv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">showType :: Bool
</span><a href="GHC.Tc.Errors.Hole.html#showType"><span class="hs-identifier hs-var">showType</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112604"><span class="hs-identifier hs-var">sType</span></a></span><span>
</span><span id="line-407"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">showMatches :: Bool
</span><a href="GHC.Tc.Errors.Hole.html#showMatches"><span class="hs-identifier hs-var">showMatches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112600"><span class="hs-identifier hs-var">sMatc</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="hs-comment">-- Which sorting algorithm to use</span><span>
</span><span id="line-410"></span><span class="hs-keyword">data</span><span> </span><span id="HoleFitSortingAlg"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitSortingAlg"><span class="hs-identifier hs-var">HoleFitSortingAlg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="HFSNoSorting"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span></span><span>      </span><span class="hs-comment">-- Do not sort the fits at all</span><span>
</span><span id="line-411"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span id="HFSBySize"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HFSBySize"><span class="hs-identifier hs-var">HFSBySize</span></a></span></span><span>         </span><span class="hs-comment">-- Sort them by the size of the match</span><span>
</span><span id="line-412"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span id="HFSBySubsumption"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HFSBySubsumption"><span class="hs-identifier hs-var">HFSBySubsumption</span></a></span></span><span>  </span><span class="hs-comment">-- Sort by full subsumption</span><span>
</span><span id="line-413"></span><span>                </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112592"><span id="local-6989586621681112594"><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
(HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; Eq HoleFitSortingAlg
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c/= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
== :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c== :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112572"><span id="local-6989586621681112574"><span id="local-6989586621681112577"><span id="local-6989586621681112580"><span id="local-6989586621681112583"><span id="local-6989586621681112585"><span id="local-6989586621681112587"><span class="annot"><span class="annottext">Eq HoleFitSortingAlg
Eq HoleFitSortingAlg
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Ordering)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg)
-&gt; (HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg)
-&gt; Ord HoleFitSortingAlg
HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Ordering
HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
min :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg
$cmin :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg
max :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg
$cmax :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; HoleFitSortingAlg
&gt;= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c&gt;= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
&gt; :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c&gt; :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
&lt;= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c&lt;= :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
&lt; :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
$c&lt; :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
compare :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Ordering
$ccompare :: HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Ordering
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></span></span></span></span></span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-414"></span><span>
</span><span id="line-415"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getHoleFitSortingAlg"><span class="hs-identifier hs-type">getHoleFitSortingAlg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitSortingAlg"><span class="hs-identifier hs-type">HoleFitSortingAlg</span></a></span><span>
</span><span id="line-416"></span><span id="getHoleFitSortingAlg"><span class="annot"><span class="annottext">getHoleFitSortingAlg :: TcM HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#getHoleFitSortingAlg"><span class="hs-identifier hs-var hs-var">getHoleFitSortingAlg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-417"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112570"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112570"><span class="hs-identifier hs-var">shouldSort</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_SortValidHoleFits"><span class="hs-identifier hs-var">Opt_SortValidHoleFits</span></a></span><span>
</span><span id="line-418"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112568"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112568"><span class="hs-identifier hs-var">subsumSort</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_SortBySubsumHoleFits"><span class="hs-identifier hs-var">Opt_SortBySubsumHoleFits</span></a></span><span>
</span><span id="line-419"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112566"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112566"><span class="hs-identifier hs-var">sizeSort</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_SortBySizeHoleFits"><span class="hs-identifier hs-var">Opt_SortBySizeHoleFits</span></a></span><span>
</span><span id="line-420"></span><span>       </span><span class="hs-comment">-- We default to sizeSort unless it has been explicitly turned off</span><span>
</span><span id="line-421"></span><span>       </span><span class="hs-comment">-- or subsumption sorting has been turned on.</span><span>
</span><span id="line-422"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; TcM HoleFitSortingAlg
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFitSortingAlg -&gt; TcM HoleFitSortingAlg)
-&gt; HoleFitSortingAlg -&gt; TcM HoleFitSortingAlg
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112570"><span class="hs-identifier hs-var">shouldSort</span></a></span><span>
</span><span id="line-423"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span><span>
</span><span id="line-424"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112568"><span class="hs-identifier hs-var">subsumSort</span></a></span><span>
</span><span id="line-425"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSBySubsumption"><span class="hs-identifier hs-var">HFSBySubsumption</span></a></span><span>
</span><span id="line-426"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112566"><span class="hs-identifier hs-var">sizeSort</span></a></span><span>
</span><span id="line-427"></span><span>                              </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSBySize"><span class="hs-identifier hs-var">HFSBySize</span></a></span><span>
</span><span id="line-428"></span><span>                              </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-429"></span><span>
</span><span id="line-430"></span><span class="hs-comment">-- If enabled, we go through the fits and add any associated documentation,</span><span>
</span><span id="line-431"></span><span class="hs-comment">-- by looking it up in the module or the environment (for local fits)</span><span>
</span><span id="line-432"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#addHoleFitDocs"><span class="hs-identifier hs-type">addHoleFitDocs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-433"></span><span id="addHoleFitDocs"><span class="annot"><span class="annottext">addHoleFitDocs :: [HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#addHoleFitDocs"><span class="hs-identifier hs-var hs-var">addHoleFitDocs</span></a></span></span><span> </span><span id="local-6989586621681112563"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112563"><span class="hs-identifier hs-var">fits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-434"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112562"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112562"><span class="hs-identifier hs-var">showDocs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ShowDocsOfHoleFits"><span class="hs-identifier hs-var">Opt_ShowDocsOfHoleFits</span></a></span><span>
</span><span id="line-435"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112562"><span class="hs-identifier hs-var">showDocs</span></a></span><span>
</span><span id="line-436"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe HsDocString
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Doc.html#DeclDocMap"><span class="hs-identifier hs-type">DeclDocMap</span></a></span><span> </span><span id="local-6989586621681112559"><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112559"><span class="hs-identifier hs-var">lclDocs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ArgDocMap
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; (Maybe HsDocString, DeclDocMap, ArgDocMap)
</span><a href="GHC.HsToCore.Docs.html#extractDocs"><span class="hs-identifier hs-var">extractDocs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcGblEnv -&gt; (Maybe HsDocString, DeclDocMap, ArgDocMap))
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Maybe HsDocString, DeclDocMap, ArgDocMap)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-437"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit)
-&gt; [HoleFit] -&gt; TcM [HoleFit]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Name HsDocString
-&gt; HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit
</span><a href="#local-6989586621681112555"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112559"><span class="hs-identifier hs-var">lclDocs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112563"><span class="hs-identifier hs-var">fits</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-438"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112563"><span class="hs-identifier hs-var">fits</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-439"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-440"></span><span>   </span><span id="local-6989586621681112554"><span class="annot"><span class="annottext">msg :: SDoc
</span><a href="#local-6989586621681112554"><span class="hs-identifier hs-var hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC.Tc.Errors.Hole addHoleFitDocs&quot;</span></span><span>
</span><span id="line-441"></span><span>   </span><span id="local-6989586621681112550"><span class="annot"><span class="annottext">lookupInIface :: Name -&gt; ModIface_ phase -&gt; Maybe HsDocString
</span><a href="#local-6989586621681112550"><span class="hs-identifier hs-var hs-var">lookupInIface</span></a></span></span><span> </span><span id="local-6989586621681112549"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112549"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#ModIface"><span class="hs-identifier hs-type">ModIface</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mi_decl_docs :: forall (phase :: ModIfacePhase). ModIface_ phase -&gt; DeclDocMap
</span><a href="GHC.Driver.Types.html#mi_decl_docs"><span class="hs-identifier hs-var">mi_decl_docs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Doc.html#DeclDocMap"><span class="hs-identifier hs-type">DeclDocMap</span></a></span><span> </span><span id="local-6989586621681112546"><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112546"><span class="hs-identifier hs-var">dmap</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-442"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Map Name HsDocString -&gt; Maybe HsDocString
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112549"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112546"><span class="hs-identifier hs-var">dmap</span></a></span><span>
</span><span id="line-443"></span><span>   </span><span id="local-6989586621681112555"><span class="annot"><span class="annottext">upd :: Map Name HsDocString
-&gt; HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit
</span><a href="#local-6989586621681112555"><span class="hs-identifier hs-var hs-var">upd</span></a></span></span><span> </span><span id="local-6989586621681112535"><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112535"><span class="hs-identifier hs-var">lclDocs</span></a></span></span><span> </span><span id="local-6989586621681112534"><span class="annot"><span class="annottext">fit :: HoleFit
</span><a href="#local-6989586621681112534"><span class="hs-identifier hs-var">fit</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">hfCand :: HoleFit -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfCand"><span class="hs-identifier hs-var">hfCand</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112531"><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112531"><span class="hs-identifier hs-var">cand</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-444"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112528"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681112528"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112531"><span class="hs-identifier hs-var">cand</span></a></span><span>
</span><span id="line-445"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112526"><span class="annot"><span class="annottext">Maybe HsDocString
</span><a href="#local-6989586621681112526"><span class="hs-identifier hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfIsLcl"><span class="hs-identifier hs-var">hfIsLcl</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112534"><span class="hs-identifier hs-var">fit</span></a></span><span>
</span><span id="line-446"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe HsDocString
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe HsDocString)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Map Name HsDocString -&gt; Maybe HsDocString
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112528"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Map Name HsDocString
</span><a href="#local-6989586621681112535"><span class="hs-identifier hs-var">lclDocs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112524"><span class="annot"><span class="annottext">Maybe ModIface
</span><a href="#local-6989586621681112524"><span class="hs-identifier hs-var">mbIface</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Name -&gt; TcRn (Maybe ModIface)
</span><a href="GHC.Iface.Load.html#loadInterfaceForNameMaybe"><span class="hs-identifier hs-var">loadInterfaceForNameMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112554"><span class="hs-identifier hs-var">msg</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112528"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-448"></span><span>                            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe HsDocString
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe HsDocString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe HsDocString
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe HsDocString))
-&gt; Maybe HsDocString
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe HsDocString)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ModIface
</span><a href="#local-6989586621681112524"><span class="hs-identifier hs-var">mbIface</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ModIface
-&gt; (ModIface -&gt; Maybe HsDocString) -&gt; Maybe HsDocString
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; ModIface -&gt; Maybe HsDocString
forall {phase :: ModIfacePhase}.
Name -&gt; ModIface_ phase -&gt; Maybe HsDocString
</span><a href="#local-6989586621681112550"><span class="hs-identifier hs-var">lookupInIface</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112528"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-449"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit)
-&gt; HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112534"><span class="hs-identifier hs-var">fit</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">hfDoc :: Maybe HsDocString
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfDoc"><span class="hs-identifier hs-var">hfDoc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe HsDocString
</span><a href="#local-6989586621681112526"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-450"></span><span>   </span><span class="annot"><a href="#local-6989586621681112555"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="annot"><span class="annottext">Map Name HsDocString
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681112522"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112522"><span class="hs-identifier hs-var">fit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; IOEnv (Env TcGblEnv TcLclEnv) HoleFit
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112522"><span class="hs-identifier hs-var">fit</span></a></span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span class="hs-comment">-- For pretty printing hole fits, we display the name and type of the fit,</span><span>
</span><span id="line-453"></span><span class="hs-comment">-- with added '_' to represent any extra arguments in case of a non-zero</span><span>
</span><span id="line-454"></span><span class="hs-comment">-- refinement level.</span><span>
</span><span id="line-455"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier hs-type">pprHoleFit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitDispConfig"><span class="hs-identifier hs-type">HoleFitDispConfig</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-456"></span><span id="pprHoleFit"><span class="annot"><span class="annottext">pprHoleFit :: HoleFitDispConfig -&gt; HoleFit -&gt; SDoc
</span><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier hs-var hs-var">pprHoleFit</span></a></span></span><span> </span><span class="annot"><span class="annottext">HoleFitDispConfig
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#RawHoleFit"><span class="hs-identifier hs-type">RawHoleFit</span></a></span><span> </span><span id="local-6989586621681112520"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112520"><span class="hs-identifier hs-var">sd</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112520"><span class="hs-identifier hs-var">sd</span></a></span><span>
</span><span id="line-457"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier hs-var">pprHoleFit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HFDC"><span class="hs-identifier hs-type">HFDC</span></a></span><span> </span><span id="local-6989586621681112519"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112519"><span class="hs-identifier hs-var">sWrp</span></a></span></span><span> </span><span id="local-6989586621681112518"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112518"><span class="hs-identifier hs-var">sWrpVars</span></a></span></span><span> </span><span id="local-6989586621681112517"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112517"><span class="hs-identifier hs-var">sTy</span></a></span></span><span> </span><span id="local-6989586621681112516"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112516"><span class="hs-identifier hs-var">sProv</span></a></span></span><span> </span><span id="local-6989586621681112515"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112515"><span class="hs-identifier hs-var">sMs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-special">{</span><span id="local-6989586621681112508"><span id="local-6989586621681112509"><span id="local-6989586621681112510"><span id="local-6989586621681112511"><span id="local-6989586621681112512"><span id="local-6989586621681112513"><span id="local-6989586621681112514"><span class="annot"><span class="annottext">Int
[TcType]
Maybe HsDocString
Id
TcType
HoleFitCandidate
hfWrap :: HoleFit -&gt; [TcType]
hfType :: HoleFit -&gt; TcType
hfRefLvl :: HoleFit -&gt; Int
hfMatches :: HoleFit -&gt; [TcType]
hfId :: HoleFit -&gt; Id
hfDoc :: Maybe HsDocString
hfMatches :: [TcType]
hfWrap :: [TcType]
hfRefLvl :: Int
hfType :: TcType
hfCand :: HoleFitCandidate
hfId :: Id
hfDoc :: HoleFit -&gt; Maybe HsDocString
hfCand :: HoleFit -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-458"></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112501"><span class="hs-identifier hs-var">display</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112500"><span class="hs-identifier hs-var">provenance</span></a></span><span>
</span><span id="line-459"></span><span> </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112498"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681112498"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">HoleFitCandidate -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112513"><span class="hs-identifier hs-var">hfCand</span></a></span><span>
</span><span id="line-460"></span><span>       </span><span id="local-6989586621681112496"><span class="annot"><span class="annottext">tyApp :: SDoc
</span><a href="#local-6989586621681112496"><span class="hs-identifier hs-var hs-var">tyApp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
-&gt; (VarBndr Id ArgFlag -&gt; TcType -&gt; SDoc)
-&gt; [VarBndr Id ArgFlag]
-&gt; [TcType]
-&gt; [SDoc]
forall a b c. String -&gt; (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="GHC.Utils.Misc.html#zipWithEqual"><span class="hs-identifier hs-var">zipWithEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pprHoleFit&quot;</span></span><span> </span><span class="annot"><span class="annottext">VarBndr Id ArgFlag -&gt; TcType -&gt; SDoc
forall {tv}. Outputable tv =&gt; VarBndr tv ArgFlag -&gt; TcType -&gt; SDoc
</span><a href="#local-6989586621681112493"><span class="hs-identifier hs-var">pprArg</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112492"><span class="hs-identifier hs-var">vars</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112510"><span class="hs-identifier hs-var">hfWrap</span></a></span><span>
</span><span id="line-461"></span><span>         </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112493"><span class="annot"><span class="annottext">pprArg :: VarBndr tv ArgFlag -&gt; TcType -&gt; SDoc
</span><a href="#local-6989586621681112493"><span class="hs-identifier hs-var hs-var">pprArg</span></a></span></span><span> </span><span id="local-6989586621681112484"><span class="annot"><span class="annottext">VarBndr tv ArgFlag
</span><a href="#local-6989586621681112484"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681112483"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112483"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarBndr tv ArgFlag -&gt; ArgFlag
forall tv argf. VarBndr tv argf -&gt; argf
</span><a href="GHC.Types.Var.html#binderArgFlag"><span class="hs-identifier hs-var">binderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr tv ArgFlag
</span><a href="#local-6989586621681112484"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-462"></span><span>                                </span><span class="hs-comment">-- See Note [Explicit Case Statement for Specificity]</span><span>
</span><span id="line-463"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Invisible"><span class="hs-identifier hs-type">Invisible</span></a></span><span> </span><span id="local-6989586621681112480"><span class="annot"><span class="annottext">Specificity
</span><a href="#local-6989586621681112480"><span class="hs-identifier hs-var">spec</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Specificity
</span><a href="#local-6989586621681112480"><span class="hs-identifier hs-var">spec</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-464"></span><span>                                  </span><span class="annot"><span class="annottext">Specificity
</span><a href="GHC.Types.Var.html#SpecifiedSpec"><span class="hs-identifier hs-var">SpecifiedSpec</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;@&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprParendType"><span class="hs-identifier hs-var">pprParendType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112483"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-465"></span><span>                                  </span><span class="hs-comment">-- Do not print type application for inferred</span><span>
</span><span id="line-466"></span><span>                                  </span><span class="hs-comment">-- variables (#16456)</span><span>
</span><span id="line-467"></span><span>                                  </span><span class="annot"><span class="annottext">Specificity
</span><a href="GHC.Types.Var.html#InferredSpec"><span class="hs-identifier hs-var">InferredSpec</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-468"></span><span>                                </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="GHC.Types.Var.html#Required"><span class="hs-identifier hs-var">Required</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; SDoc
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pprHoleFit: bad Required&quot;</span></span><span>
</span><span id="line-469"></span><span>                                                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarBndr tv ArgFlag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr tv ArgFlag
</span><a href="#local-6989586621681112484"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112483"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>       </span><span id="local-6989586621681112469"><span class="annot"><span class="annottext">tyAppVars :: SDoc
</span><a href="#local-6989586621681112469"><span class="hs-identifier hs-var hs-var">tyAppVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; [SDoc]) -&gt; [SDoc] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-471"></span><span>           </span><span class="annot"><span class="annottext">String
-&gt; (VarBndr Id ArgFlag -&gt; TcType -&gt; SDoc)
-&gt; [VarBndr Id ArgFlag]
-&gt; [TcType]
-&gt; [SDoc]
forall a b c. String -&gt; (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="GHC.Utils.Misc.html#zipWithEqual"><span class="hs-identifier hs-var">zipWithEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pprHoleFit&quot;</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681112466"><span class="annot"><span class="annottext">VarBndr Id ArgFlag
</span><a href="#local-6989586621681112466"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621681112465"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112465"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarBndr Id ArgFlag -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr Id ArgFlag
</span><a href="#local-6989586621681112466"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-472"></span><span>                                               </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprParendType"><span class="hs-identifier hs-var">pprParendType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112465"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>           </span><span class="annot"><span class="annottext">[VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112492"><span class="hs-identifier hs-var">vars</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112510"><span class="hs-identifier hs-var">hfWrap</span></a></span><span>
</span><span id="line-474"></span><span>
</span><span id="line-475"></span><span>       </span><span id="local-6989586621681112492"><span class="annot"><span class="annottext">vars :: [VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112492"><span class="hs-identifier hs-var hs-var">vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; [VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112463"><span class="hs-identifier hs-var">unwrapTypeVars</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112512"><span class="hs-identifier hs-var">hfType</span></a></span><span>
</span><span id="line-476"></span><span>         </span><span class="hs-keyword">where</span><span>
</span><span id="line-477"></span><span>           </span><span class="hs-comment">-- Attempts to get all the quantified type variables in a type,</span><span>
</span><span id="line-478"></span><span>           </span><span class="hs-comment">-- e.g.</span><span>
</span><span id="line-479"></span><span>           </span><span class="hs-comment">-- return :: forall (m :: * -&gt; *) Monad m =&gt; (forall a . a -&gt; m a)</span><span>
</span><span id="line-480"></span><span>           </span><span class="hs-comment">-- into [m, a]</span><span>
</span><span id="line-481"></span><span>           </span><span class="annot"><a href="#local-6989586621681112463"><span class="hs-identifier hs-type">unwrapTypeVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVarBinder"><span class="hs-identifier hs-type">TyCoVarBinder</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-482"></span><span>           </span><span id="local-6989586621681112463"><span class="annot"><span class="annottext">unwrapTypeVars :: TcType -&gt; [VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112463"><span class="hs-identifier hs-var hs-var">unwrapTypeVars</span></a></span></span><span> </span><span id="local-6989586621681112460"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112460"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112459"><span class="hs-identifier hs-var">vars</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr Id ArgFlag]
-&gt; [VarBndr Id ArgFlag] -&gt; [VarBndr Id ArgFlag]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType, TcType)
</span><a href="GHC.Core.Type.html#splitFunTy_maybe"><span class="hs-identifier hs-var">splitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112457"><span class="hs-identifier hs-var">unforalled</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-483"></span><span>                               </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112456"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112456"><span class="hs-identifier hs-var">unfunned</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; [VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112463"><span class="hs-identifier hs-var">unwrapTypeVars</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112456"><span class="hs-identifier hs-var">unfunned</span></a></span><span>
</span><span id="line-484"></span><span>                               </span><span class="annot"><span class="annottext">Maybe (TcType, TcType, TcType)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-485"></span><span>             </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112459"><span class="annot"><span class="annottext">[VarBndr Id ArgFlag]
</span><a href="#local-6989586621681112459"><span class="hs-identifier hs-var">vars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112457"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112457"><span class="hs-identifier hs-var">unforalled</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([VarBndr Id ArgFlag], TcType)
</span><a href="GHC.Core.Type.html#splitForAllVarBndrs"><span class="hs-identifier hs-var">splitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112460"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-486"></span><span>       </span><span id="local-6989586621681112453"><span class="annot"><span class="annottext">holeVs :: SDoc
</span><a href="#local-6989586621681112453"><span class="hs-identifier hs-var hs-var">holeVs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; SDoc) -&gt; [TcType] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; (TcType -&gt; SDoc) -&gt; TcType -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; (TcType -&gt; SDoc) -&gt; TcType -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112509"><span class="hs-identifier hs-var">hfMatches</span></a></span><span>
</span><span id="line-487"></span><span>       </span><span id="local-6989586621681112448"><span class="annot"><span class="annottext">holeDisp :: SDoc
</span><a href="#local-6989586621681112448"><span class="hs-identifier hs-var hs-var">holeDisp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112515"><span class="hs-identifier hs-var">sMs</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112453"><span class="hs-identifier hs-var">holeVs</span></a></span><span>
</span><span id="line-488"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; [SDoc]
forall a. Int -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112509"><span class="hs-identifier hs-var">hfMatches</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; [SDoc]) -&gt; SDoc -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_&quot;</span></span><span>
</span><span id="line-489"></span><span>       </span><span id="local-6989586621681112443"><span class="annot"><span class="annottext">occDisp :: SDoc
</span><a href="#local-6989586621681112443"><span class="hs-identifier hs-var hs-var">occDisp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. OutputableBndr a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#pprPrefixOcc"><span class="hs-identifier hs-var">pprPrefixOcc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112498"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-490"></span><span>       </span><span id="local-6989586621681112440"><span class="annot"><span class="annottext">tyDisp :: SDoc
</span><a href="#local-6989586621681112440"><span class="hs-identifier hs-var hs-var">tyDisp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112517"><span class="hs-identifier hs-var">sTy</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112512"><span class="hs-identifier hs-var">hfType</span></a></span><span>
</span><span id="line-491"></span><span>       </span><span id="local-6989586621681112437"><span class="annot"><span class="annottext">has :: [a] -&gt; Bool
</span><a href="#local-6989586621681112437"><span class="hs-identifier hs-var hs-var">has</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; ([a] -&gt; Bool) -&gt; [a] -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span>
</span><span id="line-492"></span><span>       </span><span id="local-6989586621681112435"><span class="annot"><span class="annottext">wrapDisp :: SDoc
</span><a href="#local-6989586621681112435"><span class="hs-identifier hs-var hs-var">wrapDisp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall {a}. [a] -&gt; Bool
</span><a href="#local-6989586621681112437"><span class="hs-identifier hs-var">has</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112510"><span class="hs-identifier hs-var">hfWrap</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112519"><span class="hs-identifier hs-var">sWrp</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112518"><span class="hs-identifier hs-var">sWrpVars</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-493"></span><span>                   </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;with&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112519"><span class="hs-identifier hs-var">sWrp</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112517"><span class="hs-identifier hs-var">sTy</span></a></span><span>
</span><span id="line-494"></span><span>                                     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112443"><span class="hs-identifier hs-var">occDisp</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112496"><span class="hs-identifier hs-var">tyApp</span></a></span><span>
</span><span id="line-495"></span><span>                                     </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112469"><span class="hs-identifier hs-var">tyAppVars</span></a></span><span>
</span><span id="line-496"></span><span>       </span><span id="local-6989586621681112432"><span class="annot"><span class="annottext">docs :: SDoc
</span><a href="#local-6989586621681112432"><span class="hs-identifier hs-var hs-var">docs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe HsDocString
</span><a href="#local-6989586621681112508"><span class="hs-identifier hs-var">hfDoc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-497"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681112431"><span class="annot"><span class="annottext">HsDocString
</span><a href="#local-6989586621681112431"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;{-^&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span>
</span><span id="line-498"></span><span>                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; (HsDocString -&gt; [SDoc]) -&gt; HsDocString -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; SDoc) -&gt; [String] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; [SDoc])
-&gt; (HsDocString -&gt; [String]) -&gt; HsDocString -&gt; [SDoc]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; [String])
-&gt; (HsDocString -&gt; String) -&gt; HsDocString -&gt; [String]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HsDocString -&gt; String
</span><a href="GHC.Hs.Doc.html#unpackHDS"><span class="hs-identifier hs-var">unpackHDS</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">HsDocString
</span><a href="#local-6989586621681112431"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-499"></span><span>                          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-}&quot;</span></span><span>
</span><span id="line-500"></span><span>                </span><span class="annot"><span class="annottext">Maybe HsDocString
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-501"></span><span>       </span><span id="local-6989586621681112428"><span class="annot"><span class="annottext">funcInfo :: SDoc
</span><a href="#local-6989586621681112428"><span class="hs-identifier hs-var hs-var">funcInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall {a}. [a] -&gt; Bool
</span><a href="#local-6989586621681112437"><span class="hs-identifier hs-var">has</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112509"><span class="hs-identifier hs-var">hfMatches</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112517"><span class="hs-identifier hs-var">sTy</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-502"></span><span>                    </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;where&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112443"><span class="hs-identifier hs-var">occDisp</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112440"><span class="hs-identifier hs-var">tyDisp</span></a></span><span>
</span><span id="line-503"></span><span>       </span><span id="local-6989586621681112427"><span class="annot"><span class="annottext">subDisp :: SDoc
</span><a href="#local-6989586621681112427"><span class="hs-identifier hs-var hs-var">subDisp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112443"><span class="hs-identifier hs-var">occDisp</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall {a}. [a] -&gt; Bool
</span><a href="#local-6989586621681112437"><span class="hs-identifier hs-var">has</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112509"><span class="hs-identifier hs-var">hfMatches</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112448"><span class="hs-identifier hs-var">holeDisp</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112440"><span class="hs-identifier hs-var">tyDisp</span></a></span><span>
</span><span id="line-504"></span><span>       </span><span id="local-6989586621681112501"><span class="annot"><span class="annottext">display :: SDoc
</span><a href="#local-6989586621681112501"><span class="hs-identifier hs-var hs-var">display</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112427"><span class="hs-identifier hs-var">subDisp</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112428"><span class="hs-identifier hs-var">funcInfo</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%2B%24"><span class="hs-operator hs-var">$+$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112432"><span class="hs-identifier hs-var">docs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%2B%24"><span class="hs-operator hs-var">$+$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112435"><span class="hs-identifier hs-var">wrapDisp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-505"></span><span>       </span><span id="local-6989586621681112500"><span class="annot"><span class="annottext">provenance :: SDoc
</span><a href="#local-6989586621681112500"><span class="hs-identifier hs-var hs-var">provenance</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112516"><span class="hs-identifier hs-var">sProv</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-506"></span><span>             </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112513"><span class="hs-identifier hs-var">hfCand</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-507"></span><span>                 </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#GreHFCand"><span class="hs-identifier hs-type">GreHFCand</span></a></span><span> </span><span id="local-6989586621681112418"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681112418"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; SDoc
</span><a href="GHC.Types.Name.Reader.html#pprNameProvenance"><span class="hs-identifier hs-var">pprNameProvenance</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681112418"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-508"></span><span>                 </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;bound at&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SrcLoc -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcLoc
forall a. NamedThing a =&gt; a -&gt; SrcLoc
</span><a href="GHC.Types.Name.html#getSrcLoc"><span class="hs-identifier hs-var">getSrcLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112498"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#getLocalBindings"><span class="hs-identifier hs-type">getLocalBindings</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-511"></span><span id="getLocalBindings"><span class="annot"><span class="annottext">getLocalBindings :: TidyEnv -&gt; CtLoc -&gt; TcM [Id]
</span><a href="GHC.Tc.Errors.Hole.html#getLocalBindings"><span class="hs-identifier hs-var hs-var">getLocalBindings</span></a></span></span><span> </span><span id="local-6989586621681112416"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112416"><span class="hs-identifier hs-var">tidy_orig</span></a></span></span><span> </span><span id="local-6989586621681112415"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112415"><span class="hs-identifier hs-var">ct_loc</span></a></span></span><span>
</span><span id="line-512"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112414"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112414"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; CtOrigin -&gt; TcM (TidyEnv, CtOrigin)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112416"><span class="hs-identifier hs-var">tidy_orig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Constraint.html#ctLocOrigin"><span class="hs-identifier hs-var">ctLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112415"><span class="hs-identifier hs-var">ct_loc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-513"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [Id] -&gt; [TcBinder] -&gt; TcM [Id]
</span><a href="#local-6989586621681112411"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112414"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcBinder] -&gt; [TcBinder]
forall a. HasOccName a =&gt; [a] -&gt; [a]
</span><a href="GHC.Tc.Types.html#removeBindingShadowing"><span class="hs-identifier hs-var">removeBindingShadowing</span></a></span><span> </span><span class="annot"><span class="annottext">([TcBinder] -&gt; [TcBinder]) -&gt; [TcBinder] -&gt; [TcBinder]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; [TcBinder]
</span><a href="GHC.Tc.Types.html#tcl_bndrs"><span class="hs-identifier hs-var hs-var">tcl_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681112408"><span class="hs-identifier hs-var">lcl_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-514"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-515"></span><span>    </span><span id="local-6989586621681112408"><span class="annot"><span class="annottext">lcl_env :: TcLclEnv
</span><a href="#local-6989586621681112408"><span class="hs-identifier hs-var hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcLclEnv
</span><a href="GHC.Tc.Types.Constraint.html#ctLocEnv"><span class="hs-identifier hs-var">ctLocEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112415"><span class="hs-identifier hs-var">ct_loc</span></a></span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span>    </span><span class="annot"><a href="#local-6989586621681112411"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcBinder"><span class="hs-identifier hs-type">TcBinder</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-518"></span><span>    </span><span id="local-6989586621681112411"><span class="annot"><span class="annottext">go :: TidyEnv -&gt; [Id] -&gt; [TcBinder] -&gt; TcM [Id]
</span><a href="#local-6989586621681112411"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681112406"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112406"><span class="hs-identifier hs-var">sofar</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM [Id]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112406"><span class="hs-identifier hs-var">sofar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span>    </span><span class="annot"><a href="#local-6989586621681112411"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681112404"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112404"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681112403"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112403"><span class="hs-identifier hs-var">sofar</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112402"><span class="annot"><span class="annottext">TcBinder
</span><a href="#local-6989586621681112402"><span class="hs-identifier hs-var">tc_bndr</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681112401"><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681112401"><span class="hs-identifier hs-var">tc_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-520"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcBinder
</span><a href="#local-6989586621681112402"><span class="hs-identifier hs-var">tc_bndr</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-521"></span><span>          </span><span class="annot"><a href="GHC.Tc.Types.html#TcIdBndr"><span class="hs-identifier hs-type">TcIdBndr</span></a></span><span> </span><span id="local-6989586621681112399"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112399"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcM [Id]
</span><a href="#local-6989586621681112398"><span class="hs-identifier hs-var">keep_it</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112399"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-522"></span><span>          </span><span class="annot"><span class="annottext">TcBinder
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM [Id]
</span><a href="#local-6989586621681112397"><span class="hs-identifier hs-var">discard_it</span></a></span><span>
</span><span id="line-523"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-524"></span><span>        </span><span id="local-6989586621681112397"><span class="annot"><span class="annottext">discard_it :: TcM [Id]
</span><a href="#local-6989586621681112397"><span class="hs-identifier hs-var hs-var">discard_it</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [Id] -&gt; [TcBinder] -&gt; TcM [Id]
</span><a href="#local-6989586621681112411"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112404"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112403"><span class="hs-identifier hs-var">sofar</span></a></span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681112401"><span class="hs-identifier hs-var">tc_bndrs</span></a></span><span>
</span><span id="line-525"></span><span>        </span><span id="local-6989586621681112398"><span class="annot"><span class="annottext">keep_it :: Id -&gt; TcM [Id]
</span><a href="#local-6989586621681112398"><span class="hs-identifier hs-var hs-var">keep_it</span></a></span></span><span> </span><span id="local-6989586621681112396"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112396"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [Id] -&gt; [TcBinder] -&gt; TcM [Id]
</span><a href="#local-6989586621681112411"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112404"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112396"><span class="hs-identifier hs-var">id</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112403"><span class="hs-identifier hs-var">sofar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681112401"><span class="hs-identifier hs-var">tc_bndrs</span></a></span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span>
</span><span id="line-528"></span><span>
</span><span id="line-529"></span><span class="hs-comment">-- See Note [Valid hole fits include ...]</span><span>
</span><span id="line-530"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#findValidHoleFits"><span class="hs-identifier hs-type">findValidHoleFits</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>        </span><span class="hs-comment">-- ^ The tidy_env for zonking</span><span>
</span><span id="line-531"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- ^ Enclosing implications for givens</span><span>
</span><span id="line-532"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-533"></span><span>                  </span><span class="hs-comment">-- ^ The  unsolved simple constraints in the implication for</span><span>
</span><span id="line-534"></span><span>                  </span><span class="hs-comment">-- the hole.</span><span>
</span><span id="line-535"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span>
</span><span id="line-536"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-537"></span><span id="findValidHoleFits"><span class="annot"><span class="annottext">findValidHoleFits :: TidyEnv -&gt; [Implication] -&gt; [Ct] -&gt; Hole -&gt; TcM (TidyEnv, SDoc)
</span><a href="GHC.Tc.Errors.Hole.html#findValidHoleFits"><span class="hs-identifier hs-var hs-var">findValidHoleFits</span></a></span></span><span> </span><span id="local-6989586621681112395"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112395"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span> </span><span id="local-6989586621681112394"><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681112394"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span id="local-6989586621681112393"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681112393"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span id="local-6989586621681112392"><span class="annot"><span class="annottext">h :: Hole
</span><a href="#local-6989586621681112392"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_sort :: Hole -&gt; HoleSort
</span><a href="GHC.Tc.Types.Constraint.html#hole_sort"><span class="hs-identifier hs-var">hole_sort</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#ExprHole"><span class="hs-identifier hs-type">ExprHole</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-538"></span><span>                                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_loc :: Hole -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#hole_loc"><span class="hs-identifier hs-var">hole_loc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112387"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112387"><span class="hs-identifier hs-var">ct_loc</span></a></span></span><span>
</span><span id="line-539"></span><span>                                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Hole -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112385"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112385"><span class="hs-identifier hs-var">hole_ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-540"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112384"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681112384"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-541"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112382"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112382"><span class="hs-identifier hs-var">lclBinds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; CtLoc -&gt; TcM [Id]
</span><a href="GHC.Tc.Errors.Hole.html#getLocalBindings"><span class="hs-identifier hs-var">getLocalBindings</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112395"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112387"><span class="hs-identifier hs-var">ct_loc</span></a></span><span>
</span><span id="line-542"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112381"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112381"><span class="hs-identifier hs-var">maxVSubs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Maybe Int
</span><a href="GHC.Driver.Session.html#maxValidHoleFits"><span class="hs-identifier hs-var hs-var">maxValidHoleFits</span></a></span><span> </span><span class="annot"><span class="annottext">(DynFlags -&gt; Maybe Int)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) DynFlags
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Int)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-543"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112378"><span class="annot"><span class="annottext">HoleFitDispConfig
</span><a href="#local-6989586621681112378"><span class="hs-identifier hs-var">hfdc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM HoleFitDispConfig
</span><a href="GHC.Tc.Errors.Hole.html#getHoleFitDispConfig"><span class="hs-identifier hs-var">getHoleFitDispConfig</span></a></span><span>
</span><span id="line-544"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112377"><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="#local-6989586621681112377"><span class="hs-identifier hs-var">sortingAlg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#getHoleFitSortingAlg"><span class="hs-identifier hs-var">getHoleFitSortingAlg</span></a></span><span>
</span><span id="line-545"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112376"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681112376"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-546"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112375"><span class="annot"><span class="annottext">[HoleFitPlugin]
</span><a href="#local-6989586621681112375"><span class="hs-identifier hs-var">hfPlugs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [HoleFitPlugin]
</span><a href="GHC.Tc.Types.html#tcg_hf_plugins"><span class="hs-identifier hs-var hs-var">tcg_hf_plugins</span></a></span><span> </span><span class="annot"><span class="annottext">(TcGblEnv -&gt; [HoleFitPlugin])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [HoleFitPlugin]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-547"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112372"><span class="annot"><span class="annottext">findVLimit :: Maybe Int
</span><a href="#local-6989586621681112372"><span class="hs-identifier hs-var hs-var">findVLimit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="#local-6989586621681112377"><span class="hs-identifier hs-var">sortingAlg</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112381"><span class="hs-identifier hs-var">maxVSubs</span></a></span><span>
</span><span id="line-548"></span><span>           </span><span id="local-6989586621681112370"><span class="annot"><span class="annottext">refLevel :: Maybe Int
</span><a href="#local-6989586621681112370"><span class="hs-identifier hs-var hs-var">refLevel</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Maybe Int
</span><a href="GHC.Driver.Session.html#refLevelHoleFits"><span class="hs-identifier hs-var hs-var">refLevelHoleFits</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681112376"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-549"></span><span>           </span><span id="local-6989586621681112368"><span class="annot"><span class="annottext">hole :: TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypedHole :: Cts -&gt; [Implication] -&gt; Maybe Hole -&gt; TypedHole
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#TypedHole"><span class="hs-identifier hs-type">TypedHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">th_relevant_cts :: Cts
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_relevant_cts"><span class="hs-identifier hs-var">th_relevant_cts</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-550"></span><span>                                </span><span class="annot"><span class="annottext">[Ct] -&gt; Cts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; [Ct] -&gt; [Ct]
</span><a href="GHC.Tc.Errors.Hole.html#relevantCts"><span class="hs-identifier hs-var">relevantCts</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112385"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681112393"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">th_implics :: [Implication]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_implics"><span class="hs-identifier hs-var">th_implics</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681112394"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-552"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">th_hole :: Maybe Hole
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_hole"><span class="hs-identifier hs-var">th_hole</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Hole -&gt; Maybe Hole
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Hole
</span><a href="#local-6989586621681112392"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-553"></span><span>           </span><span class="hs-special">(</span><span id="local-6989586621681112362"><span class="annot"><span class="annottext">[[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]]
</span><a href="#local-6989586621681112362"><span class="hs-identifier hs-var">candidatePlugins</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112361"><span class="annot"><span class="annottext">[[HoleFit] -&gt; TcM [HoleFit]]
</span><a href="#local-6989586621681112361"><span class="hs-identifier hs-var">fitPlugins</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-554"></span><span>             </span><span class="annot"><span class="annottext">[([HoleFitCandidate] -&gt; TcM [HoleFitCandidate],
  [HoleFit] -&gt; TcM [HoleFit])]
-&gt; ([[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]],
    [[HoleFit] -&gt; TcM [HoleFit]])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">([([HoleFitCandidate] -&gt; TcM [HoleFitCandidate],
   [HoleFit] -&gt; TcM [HoleFit])]
 -&gt; ([[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]],
     [[HoleFit] -&gt; TcM [HoleFit]]))
-&gt; [([HoleFitCandidate] -&gt; TcM [HoleFitCandidate],
     [HoleFit] -&gt; TcM [HoleFit])]
-&gt; ([[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]],
    [[HoleFit] -&gt; TcM [HoleFit]])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFitPlugin
 -&gt; ([HoleFitCandidate] -&gt; TcM [HoleFitCandidate],
     [HoleFit] -&gt; TcM [HoleFit]))
-&gt; [HoleFitPlugin]
-&gt; [([HoleFitCandidate] -&gt; TcM [HoleFitCandidate],
     [HoleFit] -&gt; TcM [HoleFit])]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681112359"><span class="annot"><span class="annottext">HoleFitPlugin
</span><a href="#local-6989586621681112359"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFitPlugin -&gt; CandPlugin
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#candPlugin"><span class="hs-identifier hs-var hs-var">candPlugin</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitPlugin
</span><a href="#local-6989586621681112359"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFitPlugin -&gt; FitPlugin
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#fitPlugin"><span class="hs-identifier hs-var hs-var">fitPlugin</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitPlugin
</span><a href="#local-6989586621681112359"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFitPlugin]
</span><a href="#local-6989586621681112375"><span class="hs-identifier hs-var">hfPlugs</span></a></span><span>
</span><span id="line-555"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;findingValidHoleFitsFor { &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-556"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;hole_lvl is:&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681112355"><span class="hs-identifier hs-var">hole_lvl</span></a></span><span>
</span><span id="line-557"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simples are: &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681112393"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-558"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;locals are: &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112382"><span class="hs-identifier hs-var">lclBinds</span></a></span><span>
</span><span id="line-559"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112354"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681112354"><span class="hs-identifier hs-var">lcl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112353"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681112353"><span class="hs-identifier hs-var">gbl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool)
-&gt; [GlobalRdrElt] -&gt; ([GlobalRdrElt], [GlobalRdrElt])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#gre_lcl"><span class="hs-identifier hs-var hs-var">gre_lcl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#globalRdrEnvElts"><span class="hs-identifier hs-var">globalRdrEnvElts</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681112384"><span class="hs-identifier hs-var">rdr_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-560"></span><span>           </span><span class="hs-comment">-- We remove binding shadowings here, but only for the local level.</span><span>
</span><span id="line-561"></span><span>           </span><span class="hs-comment">-- this is so we e.g. suggest the global fmap from the Functor class</span><span>
</span><span id="line-562"></span><span>           </span><span class="hs-comment">-- even though there is a local definition as well, such as in the</span><span>
</span><span id="line-563"></span><span>           </span><span class="hs-comment">-- Free monad example.</span><span>
</span><span id="line-564"></span><span>           </span><span id="local-6989586621681112349"><span class="annot"><span class="annottext">locals :: [HoleFitCandidate]
</span><a href="#local-6989586621681112349"><span class="hs-identifier hs-var hs-var">locals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate] -&gt; [HoleFitCandidate]
forall a. HasOccName a =&gt; [a] -&gt; [a]
</span><a href="GHC.Tc.Types.html#removeBindingShadowing"><span class="hs-identifier hs-var">removeBindingShadowing</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFitCandidate] -&gt; [HoleFitCandidate])
-&gt; [HoleFitCandidate] -&gt; [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-565"></span><span>                      </span><span class="annot"><span class="annottext">(Id -&gt; HoleFitCandidate) -&gt; [Id] -&gt; [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#IdHFCand"><span class="hs-identifier hs-var">IdHFCand</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112382"><span class="hs-identifier hs-var">lclBinds</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate] -&gt; [HoleFitCandidate] -&gt; [HoleFitCandidate]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; HoleFitCandidate)
-&gt; [GlobalRdrElt] -&gt; [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#GreHFCand"><span class="hs-identifier hs-var">GreHFCand</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681112354"><span class="hs-identifier hs-var">lcl</span></a></span><span>
</span><span id="line-566"></span><span>           </span><span id="local-6989586621681112347"><span class="annot"><span class="annottext">globals :: [HoleFitCandidate]
</span><a href="#local-6989586621681112347"><span class="hs-identifier hs-var hs-var">globals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; HoleFitCandidate)
-&gt; [GlobalRdrElt] -&gt; [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#GreHFCand"><span class="hs-identifier hs-var">GreHFCand</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681112353"><span class="hs-identifier hs-var">gbl</span></a></span><span>
</span><span id="line-567"></span><span>           </span><span id="local-6989586621681112346"><span class="annot"><span class="annottext">syntax :: [HoleFitCandidate]
</span><a href="#local-6989586621681112346"><span class="hs-identifier hs-var hs-var">syntax</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; HoleFitCandidate) -&gt; [Name] -&gt; [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#NameHFCand"><span class="hs-identifier hs-var">NameHFCand</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681112344"><span class="hs-identifier hs-var">builtIns</span></a></span><span>
</span><span id="line-568"></span><span>           </span><span id="local-6989586621681112343"><span class="annot"><span class="annottext">to_check :: [HoleFitCandidate]
</span><a href="#local-6989586621681112343"><span class="hs-identifier hs-var hs-var">to_check</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112349"><span class="hs-identifier hs-var">locals</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate] -&gt; [HoleFitCandidate] -&gt; [HoleFitCandidate]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112346"><span class="hs-identifier hs-var">syntax</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate] -&gt; [HoleFitCandidate] -&gt; [HoleFitCandidate]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112347"><span class="hs-identifier hs-var">globals</span></a></span><span>
</span><span id="line-569"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112342"><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112342"><span class="hs-identifier hs-var">cands</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">([HoleFitCandidate]
 -&gt; ([HoleFitCandidate] -&gt; TcM [HoleFitCandidate])
 -&gt; TcM [HoleFitCandidate])
-&gt; [HoleFitCandidate]
-&gt; [[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]]
-&gt; TcM [HoleFitCandidate]
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier hs-var">foldM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(([HoleFitCandidate] -&gt; TcM [HoleFitCandidate])
 -&gt; [HoleFitCandidate] -&gt; TcM [HoleFitCandidate])
-&gt; [HoleFitCandidate]
-&gt; ([HoleFitCandidate] -&gt; TcM [HoleFitCandidate])
-&gt; TcM [HoleFitCandidate]
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFitCandidate] -&gt; TcM [HoleFitCandidate])
-&gt; [HoleFitCandidate] -&gt; TcM [HoleFitCandidate]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">($)</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112343"><span class="hs-identifier hs-var">to_check</span></a></span><span> </span><span class="annot"><span class="annottext">[[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]]
</span><a href="#local-6989586621681112362"><span class="hs-identifier hs-var">candidatePlugins</span></a></span><span>
</span><span id="line-570"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;numPlugins are:&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[[HoleFitCandidate] -&gt; TcM [HoleFitCandidate]]
</span><a href="#local-6989586621681112362"><span class="hs-identifier hs-var">candidatePlugins</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-571"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112340"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112340"><span class="hs-identifier hs-var">searchDiscards</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112339"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112339"><span class="hs-identifier hs-var">subs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-572"></span><span>        </span><span class="annot"><span class="annottext">Maybe Int
-&gt; TypedHole
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier hs-var">tcFilterHoleFits</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112372"><span class="hs-identifier hs-var">findVLimit</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var">hole</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112385"><span class="hs-identifier hs-var">hole_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112342"><span class="hs-identifier hs-var">cands</span></a></span><span>
</span><span id="line-573"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112338"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112338"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112337"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112337"><span class="hs-identifier hs-var">tidy_subs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#zonkSubs"><span class="hs-identifier hs-var">zonkSubs</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112395"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112339"><span class="hs-identifier hs-var">subs</span></a></span><span>
</span><span id="line-574"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112336"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112336"><span class="hs-identifier hs-var">tidy_sorted_subs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112335"><span class="hs-identifier hs-var">sortFits</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="#local-6989586621681112377"><span class="hs-identifier hs-var">sortingAlg</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112337"><span class="hs-identifier hs-var">tidy_subs</span></a></span><span>
</span><span id="line-575"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112334"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112334"><span class="hs-identifier hs-var">plugin_handled_subs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; ([HoleFit] -&gt; TcM [HoleFit]) -&gt; TcM [HoleFit])
-&gt; [HoleFit] -&gt; [[HoleFit] -&gt; TcM [HoleFit]] -&gt; TcM [HoleFit]
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier hs-var">foldM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(([HoleFit] -&gt; TcM [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit])
-&gt; [HoleFit] -&gt; ([HoleFit] -&gt; TcM [HoleFit]) -&gt; TcM [HoleFit]
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; TcM [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">($)</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112336"><span class="hs-identifier hs-var">tidy_sorted_subs</span></a></span><span> </span><span class="annot"><span class="annottext">[[HoleFit] -&gt; TcM [HoleFit]]
</span><a href="#local-6989586621681112361"><span class="hs-identifier hs-var">fitPlugins</span></a></span><span>
</span><span id="line-576"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112333"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112333"><span class="hs-identifier hs-var">pVDisc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112332"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112332"><span class="hs-identifier hs-var">limited_subs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; [HoleFit] -&gt; (Bool, [HoleFit])
</span><a href="#local-6989586621681112331"><span class="hs-identifier hs-var">possiblyDiscard</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112381"><span class="hs-identifier hs-var">maxVSubs</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112334"><span class="hs-identifier hs-var">plugin_handled_subs</span></a></span><span>
</span><span id="line-577"></span><span>           </span><span id="local-6989586621681112330"><span class="annot"><span class="annottext">vDiscards :: Bool
</span><a href="#local-6989586621681112330"><span class="hs-identifier hs-var hs-var">vDiscards</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112333"><span class="hs-identifier hs-var">pVDisc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112340"><span class="hs-identifier hs-var">searchDiscards</span></a></span><span>
</span><span id="line-578"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112329"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112329"><span class="hs-identifier hs-var">subs_with_docs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#addHoleFitDocs"><span class="hs-identifier hs-var">addHoleFitDocs</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112332"><span class="hs-identifier hs-var">limited_subs</span></a></span><span>
</span><span id="line-579"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112327"><span class="annot"><span class="annottext">vMsg :: SDoc
</span><a href="#local-6989586621681112327"><span class="hs-identifier hs-var hs-var">vMsg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppUnless"><span class="hs-identifier hs-var">ppUnless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112329"><span class="hs-identifier hs-var">subs_with_docs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-580"></span><span>                    </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Valid hole fits include&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-581"></span><span>                      </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(HoleFit -&gt; SDoc) -&gt; [HoleFit] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; HoleFit -&gt; SDoc
</span><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier hs-var">pprHoleFit</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitDispConfig
</span><a href="#local-6989586621681112378"><span class="hs-identifier hs-var">hfdc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112329"><span class="hs-identifier hs-var">subs_with_docs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>                        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112330"><span class="hs-identifier hs-var">vDiscards</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112325"><span class="hs-identifier hs-var">subsDiscardMsg</span></a></span><span>
</span><span id="line-583"></span><span>     </span><span class="hs-comment">-- Refinement hole fits. See Note [Valid refinement hole fits include ...]</span><span>
</span><span id="line-584"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112324"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112324"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112323"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112323"><span class="hs-identifier hs-var">refMsg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112370"><span class="hs-identifier hs-var">refLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Maybe Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-585"></span><span>         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112322"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112322"><span class="hs-identifier hs-var">maxRSubs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Maybe Int
</span><a href="GHC.Driver.Session.html#maxRefHoleFits"><span class="hs-identifier hs-var hs-var">maxRefHoleFits</span></a></span><span> </span><span class="annot"><span class="annottext">(DynFlags -&gt; Maybe Int)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) DynFlags
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Int)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-586"></span><span>            </span><span class="hs-comment">-- We can use from just, since we know that Nothing &gt;= _ is False.</span><span>
</span><span id="line-587"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112315"><span class="annot"><span class="annottext">refLvls :: [Int]
</span><a href="#local-6989586621681112315"><span class="hs-identifier hs-var hs-var">refLvls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-glyph">..</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Int -&gt; Int
forall a. HasCallStack =&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromJust"><span class="hs-identifier hs-var">fromJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112370"><span class="hs-identifier hs-var">refLevel</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-588"></span><span>            </span><span class="hs-comment">-- We make a new refinement type for each level of refinement, where</span><span>
</span><span id="line-589"></span><span>            </span><span class="hs-comment">-- the level of refinement indicates number of additional arguments</span><span>
</span><span id="line-590"></span><span>            </span><span class="hs-comment">-- to allow.</span><span>
</span><span id="line-591"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112313"><span class="annot"><span class="annottext">[(TcType, [Id])]
</span><a href="#local-6989586621681112313"><span class="hs-identifier hs-var">ref_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TcType, [Id]))
-&gt; [Int] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [(TcType, [Id])]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TcType, [Id])
</span><a href="#local-6989586621681112312"><span class="hs-identifier hs-var">mkRefTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681112315"><span class="hs-identifier hs-var">refLvls</span></a></span><span>
</span><span id="line-592"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ref_tys are&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(TcType, [Id])] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(TcType, [Id])]
</span><a href="#local-6989586621681112313"><span class="hs-identifier hs-var">ref_tys</span></a></span><span>
</span><span id="line-593"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112310"><span class="annot"><span class="annottext">findRLimit :: Maybe Int
</span><a href="#local-6989586621681112310"><span class="hs-identifier hs-var hs-var">findRLimit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="#local-6989586621681112377"><span class="hs-identifier hs-var">sortingAlg</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; HoleFitSortingAlg -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-594"></span><span>                                                            </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112322"><span class="hs-identifier hs-var">maxRSubs</span></a></span><span>
</span><span id="line-595"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112309"><span class="annot"><span class="annottext">[(Bool, [HoleFit])]
</span><a href="#local-6989586621681112309"><span class="hs-identifier hs-var">refDs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((TcType, [Id]) -&gt; TcM (Bool, [HoleFit]))
-&gt; [(TcType, [Id])]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [(Bool, [HoleFit])]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((TcType, [Id]) -&gt; [HoleFitCandidate] -&gt; TcM (Bool, [HoleFit]))
-&gt; [HoleFitCandidate] -&gt; (TcType, [Id]) -&gt; TcM (Bool, [HoleFit])
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Int
-&gt; TypedHole
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier hs-var">tcFilterHoleFits</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112310"><span class="hs-identifier hs-var">findRLimit</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112368"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-596"></span><span>                              </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112342"><span class="hs-identifier hs-var">cands</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(TcType, [Id])]
</span><a href="#local-6989586621681112313"><span class="hs-identifier hs-var">ref_tys</span></a></span><span>
</span><span id="line-597"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112308"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112308"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112307"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112307"><span class="hs-identifier hs-var">tidy_rsubs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#zonkSubs"><span class="hs-identifier hs-var">zonkSubs</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112338"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; TcM (TidyEnv, [HoleFit]))
-&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Bool, [HoleFit]) -&gt; [HoleFit])
-&gt; [(Bool, [HoleFit])] -&gt; [HoleFit]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; [HoleFit]
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Bool, [HoleFit])]
</span><a href="#local-6989586621681112309"><span class="hs-identifier hs-var">refDs</span></a></span><span>
</span><span id="line-598"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112305"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112305"><span class="hs-identifier hs-var">tidy_sorted_rsubs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112335"><span class="hs-identifier hs-var">sortFits</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="#local-6989586621681112377"><span class="hs-identifier hs-var">sortingAlg</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112307"><span class="hs-identifier hs-var">tidy_rsubs</span></a></span><span>
</span><span id="line-599"></span><span>            </span><span class="hs-comment">-- For refinement substitutions we want matches</span><span>
</span><span id="line-600"></span><span>            </span><span class="hs-comment">-- like id (_ :: t), head (_ :: [t]), asTypeOf (_ :: t),</span><span>
</span><span id="line-601"></span><span>            </span><span class="hs-comment">-- and others in that vein to appear last, since these are</span><span>
</span><span id="line-602"></span><span>            </span><span class="hs-comment">-- unlikely to be the most relevant fits.</span><span>
</span><span id="line-603"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112304"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112304"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112303"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112303"><span class="hs-identifier hs-var">tidy_hole_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112308"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112385"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-604"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112299"><span class="annot"><span class="annottext">hasExactApp :: HoleFit -&gt; Bool
</span><a href="#local-6989586621681112299"><span class="hs-identifier hs-var hs-var">hasExactApp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; Bool) -&gt; [TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-identifier hs-var">tcEqType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112303"><span class="hs-identifier hs-var">tidy_hole_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([TcType] -&gt; Bool) -&gt; (HoleFit -&gt; [TcType]) -&gt; HoleFit -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-identifier hs-var hs-var">hfWrap</span></a></span><span>
</span><span id="line-605"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621681112296"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112296"><span class="hs-identifier hs-var">exact</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112295"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112295"><span class="hs-identifier hs-var">not_exact</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; Bool) -&gt; [HoleFit] -&gt; ([HoleFit], [HoleFit])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Bool
</span><a href="#local-6989586621681112299"><span class="hs-identifier hs-var">hasExactApp</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112305"><span class="hs-identifier hs-var">tidy_sorted_rsubs</span></a></span><span>
</span><span id="line-606"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112294"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112294"><span class="hs-identifier hs-var">plugin_handled_rsubs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; ([HoleFit] -&gt; TcM [HoleFit]) -&gt; TcM [HoleFit])
-&gt; [HoleFit] -&gt; [[HoleFit] -&gt; TcM [HoleFit]] -&gt; TcM [HoleFit]
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier hs-var">foldM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(([HoleFit] -&gt; TcM [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit])
-&gt; [HoleFit] -&gt; ([HoleFit] -&gt; TcM [HoleFit]) -&gt; TcM [HoleFit]
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; TcM [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">($)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-607"></span><span>                                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112295"><span class="hs-identifier hs-var">not_exact</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112296"><span class="hs-identifier hs-var">exact</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[[HoleFit] -&gt; TcM [HoleFit]]
</span><a href="#local-6989586621681112361"><span class="hs-identifier hs-var">fitPlugins</span></a></span><span>
</span><span id="line-608"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112293"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112293"><span class="hs-identifier hs-var">pRDisc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112292"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112292"><span class="hs-identifier hs-var">exact_last_rfits</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-609"></span><span>                    </span><span class="annot"><span class="annottext">Maybe Int -&gt; [HoleFit] -&gt; (Bool, [HoleFit])
</span><a href="#local-6989586621681112331"><span class="hs-identifier hs-var">possiblyDiscard</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112322"><span class="hs-identifier hs-var">maxRSubs</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; (Bool, [HoleFit])) -&gt; [HoleFit] -&gt; (Bool, [HoleFit])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112294"><span class="hs-identifier hs-var">plugin_handled_rsubs</span></a></span><span>
</span><span id="line-610"></span><span>                  </span><span id="local-6989586621681112290"><span class="annot"><span class="annottext">rDiscards :: Bool
</span><a href="#local-6989586621681112290"><span class="hs-identifier hs-var hs-var">rDiscards</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112293"><span class="hs-identifier hs-var">pRDisc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">((Bool, [HoleFit]) -&gt; Bool) -&gt; [(Bool, [HoleFit])] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; Bool
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Bool, [HoleFit])]
</span><a href="#local-6989586621681112309"><span class="hs-identifier hs-var">refDs</span></a></span><span>
</span><span id="line-611"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112289"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112289"><span class="hs-identifier hs-var">rsubs_with_docs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#addHoleFitDocs"><span class="hs-identifier hs-var">addHoleFitDocs</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112292"><span class="hs-identifier hs-var">exact_last_rfits</span></a></span><span>
</span><span id="line-612"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112304"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-613"></span><span>                </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppUnless"><span class="hs-identifier hs-var">ppUnless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112289"><span class="hs-identifier hs-var">rsubs_with_docs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-614"></span><span>                  </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Valid refinement hole fits include&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-615"></span><span>                  </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(HoleFit -&gt; SDoc) -&gt; [HoleFit] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFitDispConfig -&gt; HoleFit -&gt; SDoc
</span><a href="GHC.Tc.Errors.Hole.html#pprHoleFit"><span class="hs-identifier hs-var">pprHoleFit</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitDispConfig
</span><a href="#local-6989586621681112378"><span class="hs-identifier hs-var">hfdc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112289"><span class="hs-identifier hs-var">rsubs_with_docs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-616"></span><span>                    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppWhen"><span class="hs-identifier hs-var">ppWhen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112290"><span class="hs-identifier hs-var">rDiscards</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112288"><span class="hs-identifier hs-var">refSubsDiscardMsg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-617"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112338"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-618"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;findingValidHoleFitsFor }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-619"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112324"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112327"><span class="hs-identifier hs-var">vMsg</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681112323"><span class="hs-identifier hs-var">refMsg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-620"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-621"></span><span>    </span><span class="hs-comment">-- We extract the TcLevel from the constraint.</span><span>
</span><span id="line-622"></span><span>    </span><span id="local-6989586621681112355"><span class="annot"><span class="annottext">hole_lvl :: TcLevel
</span><a href="#local-6989586621681112355"><span class="hs-identifier hs-var hs-var">hole_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ctLocLevel"><span class="hs-identifier hs-var">ctLocLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681112387"><span class="hs-identifier hs-var">ct_loc</span></a></span><span>
</span><span id="line-623"></span><span>
</span><span id="line-624"></span><span>    </span><span class="hs-comment">-- BuiltInSyntax names like (:) and []</span><span>
</span><span id="line-625"></span><span>    </span><span class="annot"><a href="#local-6989586621681112344"><span class="hs-identifier hs-type">builtIns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-626"></span><span>    </span><span id="local-6989586621681112344"><span class="annot"><span class="annottext">builtIns :: [Name]
</span><a href="#local-6989586621681112344"><span class="hs-identifier hs-var hs-var">builtIns</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; [Name] -&gt; [Name]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isBuiltInSyntax"><span class="hs-identifier hs-var">isBuiltInSyntax</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="GHC.Builtin.Utils.html#knownKeyNames"><span class="hs-identifier hs-var">knownKeyNames</span></a></span><span>
</span><span id="line-627"></span><span>
</span><span id="line-628"></span><span>    </span><span class="hs-comment">-- We make a refinement type by adding a new type variable in front</span><span>
</span><span id="line-629"></span><span>    </span><span class="hs-comment">-- of the type of t h hole, going from e.g. [Integer] -&gt; Integer</span><span>
</span><span id="line-630"></span><span>    </span><span class="hs-comment">-- to t_a1/m[tau:1] -&gt; [Integer] -&gt; Integer. This allows the simplifier</span><span>
</span><span id="line-631"></span><span>    </span><span class="hs-comment">-- to unify the new type variable with any type, allowing us</span><span>
</span><span id="line-632"></span><span>    </span><span class="hs-comment">-- to suggest a &quot;refinement hole fit&quot;, like `(foldl1 _)` instead</span><span>
</span><span id="line-633"></span><span>    </span><span class="hs-comment">-- of only concrete hole fits like `sum`.</span><span>
</span><span id="line-634"></span><span>    </span><span class="annot"><a href="#local-6989586621681112312"><span class="hs-identifier hs-type">mkRefTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-635"></span><span>    </span><span id="local-6989586621681112312"><span class="annot"><span class="annottext">mkRefTy :: Int -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TcType, [Id])
</span><a href="#local-6989586621681112312"><span class="hs-identifier hs-var hs-var">mkRefTy</span></a></span></span><span> </span><span id="local-6989586621681112284"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112284"><span class="hs-identifier hs-var">refLvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; TcType
</span><a href="#local-6989586621681112283"><span class="hs-identifier hs-var">wrapWithVars</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; TcType) -&gt; ([Id] -&gt; [Id]) -&gt; [Id] -&gt; (TcType, [Id])
forall (a :: * -&gt; * -&gt; *) b c c'.
Arrow a =&gt;
a b c -&gt; a b c' -&gt; a b (c, c')
</span><a href="../../base/src/Control.Arrow.html#%26%26%26"><span class="hs-operator hs-var">&amp;&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; (TcType, [Id]))
-&gt; TcM [Id] -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TcType, [Id])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcM [Id]
</span><a href="#local-6989586621681112281"><span class="hs-identifier hs-var">newTyVars</span></a></span><span>
</span><span id="line-636"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112281"><span class="annot"><span class="annottext">newTyVars :: TcM [Id]
</span><a href="#local-6989586621681112281"><span class="hs-identifier hs-var hs-var">newTyVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IOEnv (Env TcGblEnv TcLclEnv) Id -&gt; TcM [Id]
forall (m :: * -&gt; *) a. Applicative m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#replicateM"><span class="hs-identifier hs-var">replicateM</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112284"><span class="hs-identifier hs-var">refLvl</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) Id -&gt; TcM [Id])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) Id -&gt; TcM [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621681112277"><span class="hs-identifier hs-var">setLvl</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) Id
-&gt; IOEnv (Env TcGblEnv TcLclEnv) Id
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span>
</span><span id="line-637"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcM TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier hs-var">newOpenTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcM TcType
-&gt; (TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) Id)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) Id
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) Id
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVar"><span class="hs-identifier hs-var">newFlexiTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-638"></span><span>            </span><span id="local-6989586621681112277"><span class="annot"><span class="annottext">setLvl :: Id -&gt; Id
</span><a href="#local-6989586621681112277"><span class="hs-identifier hs-var hs-var">setLvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; TcLevel -&gt; Id) -&gt; TcLevel -&gt; Id -&gt; Id
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcLevel -&gt; Id
</span><a href="GHC.Tc.Utils.TcType.html#setMetaTyVarTcLevel"><span class="hs-identifier hs-var">setMetaTyVarTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681112355"><span class="hs-identifier hs-var">hole_lvl</span></a></span><span>
</span><span id="line-639"></span><span>            </span><span id="local-6989586621681112283"><span class="annot"><span class="annottext">wrapWithVars :: [Id] -&gt; TcType
</span><a href="#local-6989586621681112283"><span class="hs-identifier hs-var hs-var">wrapWithVars</span></a></span></span><span> </span><span id="local-6989586621681112273"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112273"><span class="hs-identifier hs-var">vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTysMany"><span class="hs-identifier hs-var">mkVisFunTysMany</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; TcType) -&gt; [Id] -&gt; [TcType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112273"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112385"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-640"></span><span>
</span><span id="line-641"></span><span>    </span><span class="annot"><a href="#local-6989586621681112335"><span class="hs-identifier hs-type">sortFits</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#HoleFitSortingAlg"><span class="hs-identifier hs-type">HoleFitSortingAlg</span></a></span><span>    </span><span class="hs-comment">-- How we should sort the hole fits</span><span>
</span><span id="line-642"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- The subs to sort</span><span>
</span><span id="line-643"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-644"></span><span>    </span><span id="local-6989586621681112335"><span class="annot"><span class="annottext">sortFits :: HoleFitSortingAlg -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112335"><span class="hs-identifier hs-var hs-var">sortFits</span></a></span></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSNoSorting"><span class="hs-identifier hs-var">HFSNoSorting</span></a></span><span> </span><span id="local-6989586621681112270"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112270"><span class="hs-identifier hs-var">subs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112270"><span class="hs-identifier hs-var">subs</span></a></span><span>
</span><span id="line-645"></span><span>    </span><span class="annot"><a href="#local-6989586621681112335"><span class="hs-identifier hs-var">sortFits</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSBySize"><span class="hs-identifier hs-var">HFSBySize</span></a></span><span> </span><span id="local-6989586621681112269"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112269"><span class="hs-identifier hs-var">subs</span></a></span></span><span>
</span><span id="line-646"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; [HoleFit] -&gt; [HoleFit])
-&gt; TcM [HoleFit]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ([HoleFit] -&gt; [HoleFit])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsBySize"><span class="hs-identifier hs-var">sortHoleFitsBySize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112268"><span class="hs-identifier hs-var">lclFits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-647"></span><span>               </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) ([HoleFit] -&gt; [HoleFit])
-&gt; TcM [HoleFit] -&gt; TcM [HoleFit]
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsBySize"><span class="hs-identifier hs-var">sortHoleFitsBySize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112267"><span class="hs-identifier hs-var">gblFits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-648"></span><span>        </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112268"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112268"><span class="hs-identifier hs-var">lclFits</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112267"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112267"><span class="hs-identifier hs-var">gblFits</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; Bool) -&gt; [HoleFit] -&gt; ([HoleFit], [HoleFit])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#span"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfIsLcl"><span class="hs-identifier hs-var">hfIsLcl</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112269"><span class="hs-identifier hs-var">subs</span></a></span><span>
</span><span id="line-649"></span><span>    </span><span class="hs-comment">-- To sort by subsumption, we invoke the sortByGraph function, which</span><span>
</span><span id="line-650"></span><span>    </span><span class="hs-comment">-- builds the subsumption graph for the fits and then sorts them using a</span><span>
</span><span id="line-651"></span><span>    </span><span class="hs-comment">-- graph sort.  Since we want locals to come first anyway, we can sort</span><span>
</span><span id="line-652"></span><span>    </span><span class="hs-comment">-- them separately. The substitutions are already checked in local then</span><span>
</span><span id="line-653"></span><span>    </span><span class="hs-comment">-- global order, so we can get away with using span here.</span><span>
</span><span id="line-654"></span><span>    </span><span class="hs-comment">-- We use (&lt;*&gt;) to expose the parallelism, in case it becomes useful later.</span><span>
</span><span id="line-655"></span><span>    </span><span class="annot"><a href="#local-6989586621681112335"><span class="hs-identifier hs-var">sortFits</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitSortingAlg
</span><a href="GHC.Tc.Errors.Hole.html#HFSBySubsumption"><span class="hs-identifier hs-var">HFSBySubsumption</span></a></span><span> </span><span id="local-6989586621681112265"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112265"><span class="hs-identifier hs-var">subs</span></a></span></span><span>
</span><span id="line-656"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; [HoleFit] -&gt; [HoleFit])
-&gt; TcM [HoleFit]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ([HoleFit] -&gt; [HoleFit])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsByGraph"><span class="hs-identifier hs-var">sortHoleFitsByGraph</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112264"><span class="hs-identifier hs-var">lclFits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-657"></span><span>               </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) ([HoleFit] -&gt; [HoleFit])
-&gt; TcM [HoleFit] -&gt; TcM [HoleFit]
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsByGraph"><span class="hs-identifier hs-var">sortHoleFitsByGraph</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112263"><span class="hs-identifier hs-var">gblFits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-658"></span><span>        </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112264"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112264"><span class="hs-identifier hs-var">lclFits</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112263"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112263"><span class="hs-identifier hs-var">gblFits</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; Bool) -&gt; [HoleFit] -&gt; ([HoleFit], [HoleFit])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#span"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfIsLcl"><span class="hs-identifier hs-var">hfIsLcl</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112265"><span class="hs-identifier hs-var">subs</span></a></span><span>
</span><span id="line-659"></span><span>
</span><span id="line-660"></span><span>    </span><span class="annot"><a href="#local-6989586621681112325"><span class="hs-identifier hs-type">subsDiscardMsg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-661"></span><span>    </span><span id="local-6989586621681112325"><span class="annot"><span class="annottext">subsDiscardMsg :: SDoc
</span><a href="#local-6989586621681112325"><span class="hs-identifier hs-var hs-var">subsDiscardMsg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-662"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(Some hole fits suppressed;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-663"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;use -fmax-valid-hole-fits=N&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-664"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;or -fno-max-valid-hole-fits)&quot;</span></span><span>
</span><span id="line-665"></span><span>
</span><span id="line-666"></span><span>    </span><span class="annot"><a href="#local-6989586621681112288"><span class="hs-identifier hs-type">refSubsDiscardMsg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-667"></span><span>    </span><span id="local-6989586621681112288"><span class="annot"><span class="annottext">refSubsDiscardMsg :: SDoc
</span><a href="#local-6989586621681112288"><span class="hs-identifier hs-var hs-var">refSubsDiscardMsg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-668"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(Some refinement hole fits suppressed;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-669"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;use -fmax-refinement-hole-fits=N&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-670"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;or -fno-max-refinement-hole-fits)&quot;</span></span><span>
</span><span id="line-671"></span><span>
</span><span id="line-672"></span><span>
</span><span id="line-673"></span><span>    </span><span class="hs-comment">-- Based on the flags, we might possibly discard some or all the</span><span>
</span><span id="line-674"></span><span>    </span><span class="hs-comment">-- fits we've found.</span><span>
</span><span id="line-675"></span><span>    </span><span class="annot"><a href="#local-6989586621681112331"><span class="hs-identifier hs-type">possiblyDiscard</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-676"></span><span>    </span><span id="local-6989586621681112331"><span class="annot"><span class="annottext">possiblyDiscard :: Maybe Int -&gt; [HoleFit] -&gt; (Bool, [HoleFit])
</span><a href="#local-6989586621681112331"><span class="hs-identifier hs-var hs-var">possiblyDiscard</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681112262"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112262"><span class="hs-identifier hs-var">max</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681112261"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112261"><span class="hs-identifier hs-var">fits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112261"><span class="hs-identifier hs-var">fits</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; Int -&gt; Bool
forall a. [a] -&gt; Int -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthExceeds"><span class="hs-operator hs-var">`lengthExceeds`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112262"><span class="hs-identifier hs-var">max</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [HoleFit] -&gt; [HoleFit]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112262"><span class="hs-identifier hs-var">max</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112261"><span class="hs-identifier hs-var">fits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-677"></span><span>    </span><span class="annot"><a href="#local-6989586621681112331"><span class="hs-identifier hs-var">possiblyDiscard</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span id="local-6989586621681112258"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112258"><span class="hs-identifier hs-var">fits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112258"><span class="hs-identifier hs-var">fits</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-678"></span><span>
</span><span id="line-679"></span><span>
</span><span id="line-680"></span><span class="hs-comment">-- We don't (as of yet) handle holes in types, only in expressions.</span><span>
</span><span id="line-681"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#findValidHoleFits"><span class="hs-identifier hs-var">findValidHoleFits</span></a></span><span> </span><span id="local-6989586621681112257"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112257"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Hole
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112257"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-682"></span><span>
</span><span id="line-683"></span><span class="hs-comment">-- See Note [Relevant constraints]</span><span>
</span><span id="line-684"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#relevantCts"><span class="hs-identifier hs-type">relevantCts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-685"></span><span id="relevantCts"><span class="annot"><span class="annottext">relevantCts :: TcType -&gt; [Ct] -&gt; [Ct]
</span><a href="GHC.Tc.Errors.Hole.html#relevantCts"><span class="hs-identifier hs-var hs-var">relevantCts</span></a></span></span><span> </span><span id="local-6989586621681112256"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112256"><span class="hs-identifier hs-var">hole_ty</span></a></span></span><span> </span><span id="local-6989586621681112255"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681112255"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var">fvVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112253"><span class="hs-identifier hs-var">hole_fvs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-686"></span><span>                              </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; [Ct] -&gt; [Ct]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="#local-6989586621681112252"><span class="hs-identifier hs-var">isRelevant</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681112255"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621681112251"><span class="hs-identifier hs-type">ctFreeVarSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-688"></span><span>        </span><span id="local-6989586621681112251"><span class="annot"><span class="annottext">ctFreeVarSet :: Ct -&gt; VarSet
</span><a href="#local-6989586621681112251"><span class="hs-identifier hs-var hs-var">ctFreeVarSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var">fvVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(FV -&gt; VarSet) -&gt; (Ct -&gt; FV) -&gt; Ct -&gt; VarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfType"><span class="hs-identifier hs-var">tyCoFVsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; FV) -&gt; (Ct -&gt; TcType) -&gt; Ct -&gt; FV
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctPred"><span class="hs-identifier hs-var">ctPred</span></a></span><span>
</span><span id="line-689"></span><span>        </span><span id="local-6989586621681112253"><span class="annot"><span class="annottext">hole_fvs :: FV
</span><a href="#local-6989586621681112253"><span class="hs-identifier hs-var hs-var">hole_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfType"><span class="hs-identifier hs-var">tyCoFVsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112256"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-690"></span><span>        </span><span id="local-6989586621681112248"><span class="annot"><span class="annottext">hole_fv_set :: VarSet
</span><a href="#local-6989586621681112248"><span class="hs-identifier hs-var hs-var">hole_fv_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var">fvVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112253"><span class="hs-identifier hs-var">hole_fvs</span></a></span><span>
</span><span id="line-691"></span><span>        </span><span class="annot"><a href="#local-6989586621681112247"><span class="hs-identifier hs-type">anyFVMentioned</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-692"></span><span>        </span><span id="local-6989586621681112247"><span class="annot"><span class="annottext">anyFVMentioned :: Ct -&gt; Bool
</span><a href="#local-6989586621681112247"><span class="hs-identifier hs-var hs-var">anyFVMentioned</span></a></span></span><span> </span><span id="local-6989586621681112246"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681112246"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="#local-6989586621681112251"><span class="hs-identifier hs-var">ctFreeVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681112246"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681112248"><span class="hs-identifier hs-var">hole_fv_set</span></a></span><span>
</span><span id="line-693"></span><span>        </span><span class="hs-comment">-- We filter out those constraints that have no variables (since</span><span>
</span><span id="line-694"></span><span>        </span><span class="hs-comment">-- they won't be solved by finding a type for the type variable</span><span>
</span><span id="line-695"></span><span>        </span><span class="hs-comment">-- representing the hole) and also other holes, since we're not</span><span>
</span><span id="line-696"></span><span>        </span><span class="hs-comment">-- trying to find hole fits for many holes at once.</span><span>
</span><span id="line-697"></span><span>        </span><span id="local-6989586621681112252"><span class="annot"><span class="annottext">isRelevant :: Ct -&gt; Bool
</span><a href="#local-6989586621681112252"><span class="hs-identifier hs-var hs-var">isRelevant</span></a></span></span><span> </span><span id="local-6989586621681112244"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681112244"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="#local-6989586621681112251"><span class="hs-identifier hs-var">ctFreeVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681112244"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-698"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="#local-6989586621681112247"><span class="hs-identifier hs-var">anyFVMentioned</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681112244"><span class="hs-identifier hs-var">ct</span></a></span><span>
</span><span id="line-699"></span><span>
</span><span id="line-700"></span><span class="hs-comment">-- We zonk the hole fits so that the output aligns with the rest</span><span>
</span><span id="line-701"></span><span class="hs-comment">-- of the typed hole error message output.</span><span>
</span><span id="line-702"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#zonkSubs"><span class="hs-identifier hs-type">zonkSubs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-703"></span><span id="zonkSubs"><span class="annot"><span class="annottext">zonkSubs :: TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#zonkSubs"><span class="hs-identifier hs-var hs-var">zonkSubs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="#local-6989586621681112243"><span class="hs-identifier hs-var">zonkSubs'</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-704"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112243"><span class="annot"><span class="annottext">zonkSubs' :: [HoleFit] -&gt; TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="#local-6989586621681112243"><span class="hs-identifier hs-var hs-var">zonkSubs'</span></a></span></span><span> </span><span id="local-6989586621681112240"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112240"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span id="local-6989586621681112239"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112239"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, [HoleFit]) -&gt; TcM (TidyEnv, [HoleFit])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112239"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112240"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-705"></span><span>        </span><span class="annot"><a href="#local-6989586621681112243"><span class="hs-identifier hs-var">zonkSubs'</span></a></span><span> </span><span id="local-6989586621681112238"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112238"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span id="local-6989586621681112237"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112237"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112236"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112236"><span class="hs-identifier hs-var">hf</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681112235"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112235"><span class="hs-identifier hs-var">hfs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112234"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112234"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112233"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112233"><span class="hs-identifier hs-var">z</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; HoleFit -&gt; TcM (TidyEnv, HoleFit)
</span><a href="#local-6989586621681112232"><span class="hs-identifier hs-var">zonkSub</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112237"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112236"><span class="hs-identifier hs-var">hf</span></a></span><span>
</span><span id="line-706"></span><span>                                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TidyEnv -&gt; [HoleFit] -&gt; TcM (TidyEnv, [HoleFit])
</span><a href="#local-6989586621681112243"><span class="hs-identifier hs-var">zonkSubs'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112233"><span class="hs-identifier hs-var">z</span></a></span><span class="annot"><span class="annottext">HoleFit -&gt; [HoleFit] -&gt; [HoleFit]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112238"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112234"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112235"><span class="hs-identifier hs-var">hfs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-707"></span><span>
</span><span id="line-708"></span><span>        </span><span class="annot"><a href="#local-6989586621681112232"><span class="hs-identifier hs-type">zonkSub</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-709"></span><span>        </span><span id="local-6989586621681112232"><span class="annot"><span class="annottext">zonkSub :: TidyEnv -&gt; HoleFit -&gt; TcM (TidyEnv, HoleFit)
</span><a href="#local-6989586621681112232"><span class="hs-identifier hs-var hs-var">zonkSub</span></a></span></span><span> </span><span id="local-6989586621681112231"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112231"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681112230"><span class="annot"><span class="annottext">hf :: HoleFit
</span><a href="#local-6989586621681112230"><span class="hs-identifier hs-var">hf</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#RawHoleFit"><span class="hs-identifier hs-type">RawHoleFit</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, HoleFit) -&gt; TcM (TidyEnv, HoleFit)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112231"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112230"><span class="hs-identifier hs-var">hf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-710"></span><span>        </span><span class="annot"><a href="#local-6989586621681112232"><span class="hs-identifier hs-var">zonkSub</span></a></span><span> </span><span id="local-6989586621681112229"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112229"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681112228"><span class="annot"><span class="annottext">hf :: HoleFit
</span><a href="#local-6989586621681112228"><span class="hs-identifier hs-var">hf</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">hfType :: HoleFit -&gt; TcType
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfType"><span class="hs-identifier hs-var">hfType</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112227"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112227"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfMatches :: HoleFit -&gt; [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfMatches"><span class="hs-identifier hs-var">hfMatches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112226"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112226"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfWrap :: HoleFit -&gt; [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-identifier hs-var">hfWrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112225"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112225"><span class="hs-identifier hs-var">wrp</span></a></span></span><span class="hs-special">}</span><span>
</span><span id="line-711"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112224"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112224"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112223"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112223"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112229"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112227"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-712"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112222"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112222"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112221"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112221"><span class="hs-identifier hs-var">m'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TcType] -&gt; TcM (TidyEnv, [TcType])
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcTypes"><span class="hs-identifier hs-var">zonkTidyTcTypes</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112224"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112226"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-713"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112219"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112219"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112218"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112218"><span class="hs-identifier hs-var">wrp'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TcType] -&gt; TcM (TidyEnv, [TcType])
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcTypes"><span class="hs-identifier hs-var">zonkTidyTcTypes</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112222"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112225"><span class="hs-identifier hs-var">wrp</span></a></span><span>
</span><span id="line-714"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112217"><span class="annot"><span class="annottext">zFit :: HoleFit
</span><a href="#local-6989586621681112217"><span class="hs-identifier hs-var hs-var">zFit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112228"><span class="hs-identifier hs-var">hf</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">hfType :: TcType
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfType"><span class="hs-identifier hs-var">hfType</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112223"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfMatches :: [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfMatches"><span class="hs-identifier hs-var">hfMatches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112221"><span class="hs-identifier hs-var">m'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfWrap :: [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-identifier hs-var">hfWrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112218"><span class="hs-identifier hs-var">wrp'</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-715"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, HoleFit) -&gt; TcM (TidyEnv, HoleFit)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681112219"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112217"><span class="hs-identifier hs-var">zFit</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-716"></span><span>
</span><span id="line-717"></span><span class="hs-comment">-- | Sort by size uses as a measure for relevance the sizes of the different</span><span>
</span><span id="line-718"></span><span class="hs-comment">-- types needed to instantiate the fit to the type of the hole.</span><span>
</span><span id="line-719"></span><span class="hs-comment">-- This is much quicker than sorting by subsumption, and gives reasonable</span><span>
</span><span id="line-720"></span><span class="hs-comment">-- results in most cases.</span><span>
</span><span id="line-721"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsBySize"><span class="hs-identifier hs-type">sortHoleFitsBySize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-722"></span><span id="sortHoleFitsBySize"><span class="annot"><span class="annottext">sortHoleFitsBySize :: [HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsBySize"><span class="hs-identifier hs-var hs-var">sortHoleFitsBySize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; TcM [HoleFit])
-&gt; ([HoleFit] -&gt; [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; TypeSize) -&gt; [HoleFit] -&gt; [HoleFit]
forall b a. Ord b =&gt; (a -&gt; b) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortOn"><span class="hs-identifier hs-var">sortOn</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; TypeSize
</span><a href="#local-6989586621681112216"><span class="hs-identifier hs-var">sizeOfFit</span></a></span><span>
</span><span id="line-723"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621681112216"><span class="hs-identifier hs-type">sizeOfFit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TypeSize"><span class="hs-identifier hs-type">TypeSize</span></a></span><span>
</span><span id="line-724"></span><span>        </span><span id="local-6989586621681112216"><span class="annot"><span class="annottext">sizeOfFit :: HoleFit -&gt; TypeSize
</span><a href="#local-6989586621681112216"><span class="hs-identifier hs-var hs-var">sizeOfFit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; TypeSize
</span><a href="GHC.Tc.Utils.TcType.html#sizeTypes"><span class="hs-identifier hs-var">sizeTypes</span></a></span><span> </span><span class="annot"><span class="annottext">([TcType] -&gt; TypeSize)
-&gt; (HoleFit -&gt; [TcType]) -&gt; HoleFit -&gt; TypeSize
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; Bool) -&gt; [TcType] -&gt; [TcType]
forall a. (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nubBy"><span class="hs-identifier hs-var">nubBy</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-identifier hs-var">tcEqType</span></a></span><span> </span><span class="annot"><span class="annottext">([TcType] -&gt; [TcType])
-&gt; (HoleFit -&gt; [TcType]) -&gt; HoleFit -&gt; [TcType]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>  </span><span class="annot"><span class="annottext">HoleFit -&gt; [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-identifier hs-var hs-var">hfWrap</span></a></span><span>
</span><span id="line-725"></span><span>
</span><span id="line-726"></span><span class="hs-comment">-- Based on a suggestion by phadej on #ghc, we can sort the found fits</span><span>
</span><span id="line-727"></span><span class="hs-comment">-- by constructing a subsumption graph, and then do a topological sort of</span><span>
</span><span id="line-728"></span><span class="hs-comment">-- the graph. This makes the most specific types appear first, which are</span><span>
</span><span id="line-729"></span><span class="hs-comment">-- probably those most relevant. This takes a lot of work (but results in</span><span>
</span><span id="line-730"></span><span class="hs-comment">-- much more useful output), and can be disabled by</span><span>
</span><span id="line-731"></span><span class="hs-comment">-- '-fno-sort-valid-hole-fits'.</span><span>
</span><span id="line-732"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsByGraph"><span class="hs-identifier hs-type">sortHoleFitsByGraph</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-733"></span><span id="sortHoleFitsByGraph"><span class="annot"><span class="annottext">sortHoleFitsByGraph :: [HoleFit] -&gt; TcM [HoleFit]
</span><a href="GHC.Tc.Errors.Hole.html#sortHoleFitsByGraph"><span class="hs-identifier hs-var hs-var">sortHoleFitsByGraph</span></a></span></span><span> </span><span id="local-6989586621681112214"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112214"><span class="hs-identifier hs-var">fits</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])] -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112213"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112214"><span class="hs-identifier hs-var">fits</span></a></span><span>
</span><span id="line-734"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621681112212"><span class="hs-identifier hs-type">tcSubsumesWCloning</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-735"></span><span>        </span><span id="local-6989586621681112212"><span class="annot"><span class="annottext">tcSubsumesWCloning :: TcType -&gt; TcType -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="#local-6989586621681112212"><span class="hs-identifier hs-var hs-var">tcSubsumesWCloning</span></a></span></span><span> </span><span id="local-6989586621681112211"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112211"><span class="hs-identifier hs-var">ht</span></a></span></span><span> </span><span id="local-6989586621681112210"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112210"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV
-&gt; TcRnIf TcGblEnv TcLclEnv Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall a. FV -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Errors.Hole.html#withoutUnification"><span class="hs-identifier hs-var">withoutUnification</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112209"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Errors.Hole.html#tcSubsumes"><span class="hs-identifier hs-var">tcSubsumes</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112211"><span class="hs-identifier hs-var">ht</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112210"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>          </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112209"><span class="annot"><span class="annottext">fvs :: FV
</span><a href="#local-6989586621681112209"><span class="hs-identifier hs-var hs-var">fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfTypes"><span class="hs-identifier hs-var">tyCoFVsOfTypes</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112211"><span class="hs-identifier hs-var">ht</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112210"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-737"></span><span>        </span><span class="annot"><a href="#local-6989586621681112213"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-738"></span><span>        </span><span id="local-6989586621681112213"><span class="annot"><span class="annottext">go :: [(HoleFit, [HoleFit])] -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112213"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681112207"><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])]
</span><a href="#local-6989586621681112207"><span class="hs-identifier hs-var">sofar</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;subsumptionGraph was&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])]
</span><a href="#local-6989586621681112207"><span class="hs-identifier hs-var">sofar</span></a></span><span>
</span><span id="line-739"></span><span>                         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; TcM [HoleFit]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; TcM [HoleFit]) -&gt; [HoleFit] -&gt; TcM [HoleFit]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">([HoleFit] -&gt; [HoleFit] -&gt; [HoleFit])
-&gt; ([HoleFit], [HoleFit]) -&gt; [HoleFit]
forall a b c. (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c
</span><a href="../../base/src/Data.Tuple.html#uncurry"><span class="hs-identifier hs-var">uncurry</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="annot"><span class="annottext">(([HoleFit], [HoleFit]) -&gt; [HoleFit])
-&gt; ([HoleFit], [HoleFit]) -&gt; [HoleFit]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; Bool) -&gt; [HoleFit] -&gt; ([HoleFit], [HoleFit])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Bool
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfIsLcl"><span class="hs-identifier hs-var">hfIsLcl</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112205"><span class="hs-identifier hs-var">topSorted</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-740"></span><span>          </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112204"><span class="annot"><span class="annottext">toV :: (HoleFit, [HoleFit]) -&gt; (HoleFit, Id, [Id])
</span><a href="#local-6989586621681112204"><span class="hs-identifier hs-var hs-var">toV</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112203"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112203"><span class="hs-identifier hs-var">hf</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112202"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112202"><span class="hs-identifier hs-var">adjs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112203"><span class="hs-identifier hs-var">hf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Id
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfId"><span class="hs-identifier hs-var hs-var">hfId</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112203"><span class="hs-identifier hs-var">hf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; Id) -&gt; [HoleFit] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; Id
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfId"><span class="hs-identifier hs-var hs-var">hfId</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112202"><span class="hs-identifier hs-var">adjs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-741"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621681112199"><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621681112199"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112198"><span class="annot"><span class="annottext">Int -&gt; (HoleFit, Id, [Id])
</span><a href="#local-6989586621681112198"><span class="hs-identifier hs-var">fromV</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(HoleFit, Id, [Id])]
-&gt; (Graph, Int -&gt; (HoleFit, Id, [Id]), Id -&gt; Maybe Int)
forall key node.
Ord key =&gt;
[(node, key, [key])]
-&gt; (Graph, Int -&gt; (node, key, [key]), key -&gt; Maybe Int)
</span><a href="../../containers/src/Data.Graph.html#graphFromEdges"><span class="hs-identifier hs-var">graphFromEdges</span></a></span><span> </span><span class="annot"><span class="annottext">([(HoleFit, Id, [Id])]
 -&gt; (Graph, Int -&gt; (HoleFit, Id, [Id]), Id -&gt; Maybe Int))
-&gt; [(HoleFit, Id, [Id])]
-&gt; (Graph, Int -&gt; (HoleFit, Id, [Id]), Id -&gt; Maybe Int)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((HoleFit, [HoleFit]) -&gt; (HoleFit, Id, [Id]))
-&gt; [(HoleFit, [HoleFit])] -&gt; [(HoleFit, Id, [Id])]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(HoleFit, [HoleFit]) -&gt; (HoleFit, Id, [Id])
</span><a href="#local-6989586621681112204"><span class="hs-identifier hs-var">toV</span></a></span><span> </span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])]
</span><a href="#local-6989586621681112207"><span class="hs-identifier hs-var">sofar</span></a></span><span>
</span><span id="line-742"></span><span>                </span><span id="local-6989586621681112205"><span class="annot"><span class="annottext">topSorted :: [HoleFit]
</span><a href="#local-6989586621681112205"><span class="hs-identifier hs-var hs-var">topSorted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; HoleFit) -&gt; [Int] -&gt; [HoleFit]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681112197"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112197"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112197"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((HoleFit, Id, [Id]) -&gt; HoleFit)
-&gt; (Int -&gt; (HoleFit, Id, [Id])) -&gt; Int -&gt; HoleFit
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; (HoleFit, Id, [Id])
</span><a href="#local-6989586621681112198"><span class="hs-identifier hs-var">fromV</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Int] -&gt; [HoleFit]) -&gt; [Int] -&gt; [HoleFit]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Graph -&gt; [Int]
</span><a href="../../containers/src/Data.Graph.html#topSort"><span class="hs-identifier hs-var">topSort</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621681112199"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-743"></span><span>        </span><span class="annot"><a href="#local-6989586621681112213"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681112196"><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])]
</span><a href="#local-6989586621681112196"><span class="hs-identifier hs-var">sofar</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112195"><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112195"><span class="hs-identifier hs-var">hf</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681112194"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112194"><span class="hs-identifier hs-var">hfs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-744"></span><span>          </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112193"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112193"><span class="hs-identifier hs-var">adjs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(HoleFit -&gt; TcRnIf TcGblEnv TcLclEnv Bool)
-&gt; [HoleFit] -&gt; TcM [HoleFit]
forall (m :: * -&gt; *) a.
Applicative m =&gt;
(a -&gt; m Bool) -&gt; [a] -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#filterM"><span class="hs-identifier hs-var">filterM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="#local-6989586621681112212"><span class="hs-identifier hs-var">tcSubsumesWCloning</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFit -&gt; TcType
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfType"><span class="hs-identifier hs-var hs-var">hfType</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112195"><span class="hs-identifier hs-var">hf</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcRnIf TcGblEnv TcLclEnv Bool)
-&gt; (HoleFit -&gt; TcType) -&gt; HoleFit -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFit -&gt; TcType
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfType"><span class="hs-identifier hs-var hs-var">hfType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112214"><span class="hs-identifier hs-var">fits</span></a></span><span>
</span><span id="line-745"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])] -&gt; [HoleFit] -&gt; TcM [HoleFit]
</span><a href="#local-6989586621681112213"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112195"><span class="hs-identifier hs-var">hf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112193"><span class="hs-identifier hs-var">adjs</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(HoleFit, [HoleFit])
-&gt; [(HoleFit, [HoleFit])] -&gt; [(HoleFit, [HoleFit])]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[(HoleFit, [HoleFit])]
</span><a href="#local-6989586621681112196"><span class="hs-identifier hs-var">sofar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112194"><span class="hs-identifier hs-var">hfs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-746"></span><span>
</span><span id="line-747"></span><span class="hs-comment">-- | tcFilterHoleFits filters the candidates by whether, given the implications</span><span>
</span><span id="line-748"></span><span class="hs-comment">-- and the relevant constraints, they can be made to match the type by</span><span>
</span><span id="line-749"></span><span class="hs-comment">-- running the type checker. Stops after finding limit matches.</span><span>
</span><span id="line-750"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier hs-type">tcFilterHoleFits</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-751"></span><span>               </span><span class="hs-comment">-- ^ How many we should output, if limited</span><span>
</span><span id="line-752"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#TypedHole"><span class="hs-identifier hs-type">TypedHole</span></a></span><span> </span><span class="hs-comment">-- ^ The hole to filter against</span><span>
</span><span id="line-753"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-754"></span><span>               </span><span class="hs-comment">-- ^ The type to check for fits and a list of refinement</span><span>
</span><span id="line-755"></span><span>               </span><span class="hs-comment">-- variables (free type variables in the type) for emulating</span><span>
</span><span id="line-756"></span><span>               </span><span class="hs-comment">-- additional holes.</span><span>
</span><span id="line-757"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFitCandidate"><span class="hs-identifier hs-type">HoleFitCandidate</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-758"></span><span>               </span><span class="hs-comment">-- ^ The candidates to check whether fit.</span><span>
</span><span id="line-759"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-760"></span><span>               </span><span class="hs-comment">-- ^ We return whether or not we stopped due to hitting the limit</span><span>
</span><span id="line-761"></span><span>               </span><span class="hs-comment">-- and the fits we found.</span><span>
</span><span id="line-762"></span><span id="tcFilterHoleFits"><span class="annot"><span class="annottext">tcFilterHoleFits :: Maybe Int
-&gt; TypedHole
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier hs-var hs-var">tcFilterHoleFits</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Stop right away on 0</span><span>
</span><span id="line-763"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcFilterHoleFits"><span class="hs-identifier hs-var">tcFilterHoleFits</span></a></span><span> </span><span id="local-6989586621681112192"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112192"><span class="hs-identifier hs-var">limit</span></a></span></span><span> </span><span id="local-6989586621681112191"><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112191"><span class="hs-identifier hs-var">typed_hole</span></a></span></span><span> </span><span id="local-6989586621681112190"><span class="annot"><span class="annottext">ht :: (TcType, [Id])
</span><a href="#local-6989586621681112190"><span class="hs-identifier hs-var">ht</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681112189"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112189"><span class="hs-identifier hs-var">hole_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681112188"><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112188"><span class="hs-identifier hs-var">candidates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-764"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkingFitsFor {&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112189"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-765"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112187"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112187"><span class="hs-identifier hs-var">discards</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112186"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112186"><span class="hs-identifier hs-var">subs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
-&gt; VarSet
-&gt; Maybe Int
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112185"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112192"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112190"><span class="hs-identifier hs-var">ht</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112188"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-766"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkingFitsFor }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-767"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112187"><span class="hs-identifier hs-var">discards</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112186"><span class="hs-identifier hs-var">subs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-768"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-769"></span><span>    </span><span class="annot"><a href="#local-6989586621681112183"><span class="hs-identifier hs-type">hole_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-770"></span><span>    </span><span id="local-6989586621681112183"><span class="annot"><span class="annottext">hole_fvs :: FV
</span><a href="#local-6989586621681112183"><span class="hs-identifier hs-var hs-var">hole_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfType"><span class="hs-identifier hs-var">tyCoFVsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112189"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-771"></span><span>    </span><span class="hs-comment">-- Kickoff the checking of the elements.</span><span>
</span><span id="line-772"></span><span>    </span><span class="hs-comment">-- We iterate over the elements, checking each one in turn for whether</span><span>
</span><span id="line-773"></span><span>    </span><span class="hs-comment">-- it fits, and adding it to the results if it does.</span><span>
</span><span id="line-774"></span><span>    </span><span class="annot"><a href="#local-6989586621681112185"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span>           </span><span class="hs-comment">-- What we've found so far.</span><span>
</span><span id="line-775"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>              </span><span class="hs-comment">-- Ids we've already checked</span><span>
</span><span id="line-776"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>           </span><span class="hs-comment">-- How many we're allowed to find, if limited</span><span>
</span><span id="line-777"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- The type, and its refinement variables.</span><span>
</span><span id="line-778"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFitCandidate"><span class="hs-identifier hs-type">HoleFitCandidate</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- The elements we've yet to check.</span><span>
</span><span id="line-779"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span>    </span><span id="local-6989586621681112185"><span class="annot"><span class="annottext">go :: [HoleFit]
-&gt; VarSet
-&gt; Maybe Int
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112185"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681112182"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112182"><span class="hs-identifier hs-var">subs</span></a></span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112182"><span class="hs-identifier hs-var">subs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-781"></span><span>    </span><span class="annot"><a href="#local-6989586621681112185"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681112181"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112181"><span class="hs-identifier hs-var">subs</span></a></span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[HoleFit] -&gt; [HoleFit]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112181"><span class="hs-identifier hs-var">subs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-782"></span><span>    </span><span class="annot"><a href="#local-6989586621681112185"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681112180"><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112180"><span class="hs-identifier hs-var">subs</span></a></span></span><span> </span><span id="local-6989586621681112179"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681112179"><span class="hs-identifier hs-var">seen</span></a></span></span><span> </span><span id="local-6989586621681112178"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112178"><span class="hs-identifier hs-var">maxleft</span></a></span></span><span> </span><span id="local-6989586621681112177"><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112177"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112176"><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112176"><span class="hs-identifier hs-var">el</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681112175"><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112175"><span class="hs-identifier hs-var">elts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-783"></span><span>        </span><span class="hs-comment">-- See Note [Leaking errors]</span><span>
</span><span id="line-784"></span><span>        </span><span class="annot"><span class="annottext">TcM (Bool, [HoleFit])
-&gt; TcM (Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall r. TcM r -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Monad.html#tryTcDiscardingErrs"><span class="hs-identifier hs-var">tryTcDiscardingErrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112173"><span class="hs-identifier hs-var">discard_it</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit]))
-&gt; TcM (Bool, [HoleFit]) -&gt; TcM (Bool, [HoleFit])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-785"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookingUp&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112176"><span class="hs-identifier hs-var">el</span></a></span><span>
</span><span id="line-786"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112172"><span class="annot"><span class="annottext">Maybe (Id, TcType)
</span><a href="#local-6989586621681112172"><span class="hs-identifier hs-var">maybeThing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate -&gt; TcM (Maybe (Id, TcType))
</span><a href="#local-6989586621681112171"><span class="hs-identifier hs-var">lookup</span></a></span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112176"><span class="hs-identifier hs-var">el</span></a></span><span>
</span><span id="line-787"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (Id, TcType)
</span><a href="#local-6989586621681112172"><span class="hs-identifier hs-var">maybeThing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-788"></span><span>               </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112170"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112170"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112169"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112169"><span class="hs-identifier hs-var">id_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681112168"><span class="hs-identifier hs-var">not_trivial</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112170"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-789"></span><span>                       </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112167"><span class="annot"><span class="annottext">Maybe ([TcType], [TcType])
</span><a href="#local-6989586621681112167"><span class="hs-identifier hs-var">fits</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcType, [Id]) -&gt; TcType -&gt; TcM (Maybe ([TcType], [TcType]))
</span><a href="#local-6989586621681112166"><span class="hs-identifier hs-var">fitsHole</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112177"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112169"><span class="hs-identifier hs-var">id_ty</span></a></span><span>
</span><span id="line-790"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType])
</span><a href="#local-6989586621681112167"><span class="hs-identifier hs-var">fits</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-791"></span><span>                              </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112165"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112165"><span class="hs-identifier hs-var">wrp</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112164"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112164"><span class="hs-identifier hs-var">matches</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcType -&gt; [TcType] -&gt; [TcType] -&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112163"><span class="hs-identifier hs-var">keep_it</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112170"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112169"><span class="hs-identifier hs-var">id_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112165"><span class="hs-identifier hs-var">wrp</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112164"><span class="hs-identifier hs-var">matches</span></a></span><span>
</span><span id="line-792"></span><span>                              </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112173"><span class="hs-identifier hs-var">discard_it</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-793"></span><span>               </span><span class="annot"><span class="annottext">Maybe (Id, TcType)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112173"><span class="hs-identifier hs-var">discard_it</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-794"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-795"></span><span>          </span><span class="hs-comment">-- We want to filter out undefined and the likes from GHC.Err</span><span>
</span><span id="line-796"></span><span>          </span><span id="local-6989586621681112168"><span class="annot"><span class="annottext">not_trivial :: Id -&gt; Bool
</span><a href="#local-6989586621681112168"><span class="hs-identifier hs-var hs-var">not_trivial</span></a></span></span><span> </span><span id="local-6989586621681112156"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112156"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe Module
</span><a href="GHC.Types.Name.html#nameModule_maybe"><span class="hs-identifier hs-var">nameModule_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112156"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Module -&gt; Maybe Module -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Module -&gt; Maybe Module
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="GHC.Builtin.Names.html#gHC_ERR"><span class="hs-identifier hs-var">gHC_ERR</span></a></span><span>
</span><span id="line-797"></span><span>
</span><span id="line-798"></span><span>          </span><span class="annot"><a href="#local-6989586621681112171"><span class="hs-identifier hs-type">lookup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFitCandidate"><span class="hs-identifier hs-type">HoleFitCandidate</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-799"></span><span>          </span><span id="local-6989586621681112171"><span class="annot"><span class="annottext">lookup :: HoleFitCandidate -&gt; TcM (Maybe (Id, TcType))
</span><a href="#local-6989586621681112171"><span class="hs-identifier hs-var hs-var">lookup</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#IdHFCand"><span class="hs-identifier hs-type">IdHFCand</span></a></span><span> </span><span id="local-6989586621681112152"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112152"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Id, TcType) -&gt; TcM (Maybe (Id, TcType))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id, TcType) -&gt; Maybe (Id, TcType)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112152"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112152"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-800"></span><span>          </span><span class="annot"><a href="#local-6989586621681112171"><span class="hs-identifier hs-var">lookup</span></a></span><span> </span><span id="local-6989586621681112150"><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112150"><span class="hs-identifier hs-var">hfc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112149"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681112149"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var">tcLookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112148"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-801"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe (Id, TcType) -&gt; TcM (Maybe (Id, TcType))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe (Id, TcType) -&gt; TcM (Maybe (Id, TcType)))
-&gt; Maybe (Id, TcType) -&gt; TcM (Maybe (Id, TcType))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681112149"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-802"></span><span>                                       </span><span class="annot"><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">tct_id :: TcTyThing -&gt; Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681112145"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112145"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Id, TcType) -&gt; Maybe (Id, TcType)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112145"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112145"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-803"></span><span>                                       </span><span class="annot"><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-type">AGlobal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AnId"><span class="hs-identifier hs-type">AnId</span></a></span><span> </span><span id="local-6989586621681112142"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112142"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Id, TcType) -&gt; Maybe (Id, TcType)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112142"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112142"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-804"></span><span>                                       </span><span class="annot"><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-type">AGlobal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681112139"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681112139"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-805"></span><span>                                           </span><span class="annot"><span class="annottext">(Id, TcType) -&gt; Maybe (Id, TcType)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Id
</span><a href="GHC.Core.DataCon.html#dataConWrapId"><span class="hs-identifier hs-var">dataConWrapId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681112139"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; TcType
</span><a href="GHC.Core.DataCon.html#dataConNonlinearType"><span class="hs-identifier hs-var">dataConNonlinearType</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681112139"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-806"></span><span>                                       </span><span class="annot"><span class="annottext">TcTyThing
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (Id, TcType)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-807"></span><span>            </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112148"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681112148"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112150"><span class="hs-identifier hs-var">hfc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-808"></span><span>                           </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#IdHFCand"><span class="hs-identifier hs-type">IdHFCand</span></a></span><span> </span><span id="local-6989586621681112136"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112136"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112136"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-809"></span><span>                           </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#GreHFCand"><span class="hs-identifier hs-type">GreHFCand</span></a></span><span> </span><span id="local-6989586621681112135"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681112135"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681112135"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-810"></span><span>                           </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#NameHFCand"><span class="hs-identifier hs-type">NameHFCand</span></a></span><span> </span><span id="local-6989586621681112133"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112133"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681112133"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-811"></span><span>          </span><span id="local-6989586621681112173"><span class="annot"><span class="annottext">discard_it :: TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112173"><span class="hs-identifier hs-var hs-var">discard_it</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
-&gt; VarSet
-&gt; Maybe Int
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112185"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112180"><span class="hs-identifier hs-var">subs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681112179"><span class="hs-identifier hs-var">seen</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112178"><span class="hs-identifier hs-var">maxleft</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112177"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112175"><span class="hs-identifier hs-var">elts</span></a></span><span>
</span><span id="line-812"></span><span>          </span><span id="local-6989586621681112163"><span class="annot"><span class="annottext">keep_it :: Id -&gt; TcType -&gt; [TcType] -&gt; [TcType] -&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112163"><span class="hs-identifier hs-var hs-var">keep_it</span></a></span></span><span> </span><span id="local-6989586621681112128"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112128"><span class="hs-identifier hs-var">eid</span></a></span></span><span> </span><span id="local-6989586621681112127"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112127"><span class="hs-identifier hs-var">eid_ty</span></a></span></span><span> </span><span id="local-6989586621681112126"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112126"><span class="hs-identifier hs-var">wrp</span></a></span></span><span> </span><span id="local-6989586621681112125"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112125"><span class="hs-identifier hs-var">ms</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[HoleFit]
-&gt; VarSet
-&gt; Maybe Int
-&gt; (TcType, [Id])
-&gt; [HoleFitCandidate]
-&gt; TcM (Bool, [HoleFit])
</span><a href="#local-6989586621681112185"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HoleFit
</span><a href="#local-6989586621681112124"><span class="hs-identifier hs-var">fit</span></a></span><span class="annot"><span class="annottext">HoleFit -&gt; [HoleFit] -&gt; [HoleFit]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[HoleFit]
</span><a href="#local-6989586621681112180"><span class="hs-identifier hs-var">subs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681112179"><span class="hs-identifier hs-var">seen</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112128"><span class="hs-identifier hs-var">eid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-813"></span><span>                                 </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681112122"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112122"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681112122"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int) -&gt; Maybe Int -&gt; Maybe Int
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621681112178"><span class="hs-identifier hs-var">maxleft</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112177"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[HoleFitCandidate]
</span><a href="#local-6989586621681112175"><span class="hs-identifier hs-var">elts</span></a></span><span>
</span><span id="line-814"></span><span>            </span><span class="hs-keyword">where</span><span>
</span><span id="line-815"></span><span>              </span><span id="local-6989586621681112124"><span class="annot"><span class="annottext">fit :: HoleFit
</span><a href="#local-6989586621681112124"><span class="hs-identifier hs-var hs-var">fit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HoleFit :: Id
-&gt; HoleFitCandidate
-&gt; TcType
-&gt; Int
-&gt; [TcType]
-&gt; [TcType]
-&gt; Maybe HsDocString
-&gt; HoleFit
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#HoleFit"><span class="hs-identifier hs-type">HoleFit</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hfId :: Id
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfId"><span class="hs-identifier hs-var">hfId</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112128"><span class="hs-identifier hs-var">eid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfCand :: HoleFitCandidate
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfCand"><span class="hs-identifier hs-var">hfCand</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HoleFitCandidate
</span><a href="#local-6989586621681112176"><span class="hs-identifier hs-var">el</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfType :: TcType
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfType"><span class="hs-identifier hs-var">hfType</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112127"><span class="hs-identifier hs-var">eid_ty</span></a></span><span>
</span><span id="line-816"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfRefLvl :: Int
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfRefLvl"><span class="hs-identifier hs-var">hfRefLvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TcType, [Id]) -&gt; [Id]
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType, [Id])
</span><a href="#local-6989586621681112177"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-817"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfWrap :: [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfWrap"><span class="hs-identifier hs-var">hfWrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112126"><span class="hs-identifier hs-var">wrp</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfMatches :: [TcType]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfMatches"><span class="hs-identifier hs-var">hfMatches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112125"><span class="hs-identifier hs-var">ms</span></a></span><span>
</span><span id="line-818"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hfDoc :: Maybe HsDocString
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#hfDoc"><span class="hs-identifier hs-var">hfDoc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe HsDocString
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-819"></span><span>
</span><span id="line-820"></span><span>
</span><span id="line-821"></span><span>
</span><span id="line-822"></span><span>
</span><span id="line-823"></span><span>    </span><span class="annot"><a href="#local-6989586621681112120"><span class="hs-identifier hs-type">unfoldWrapper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-824"></span><span>    </span><span id="local-6989586621681112120"><span class="annot"><span class="annottext">unfoldWrapper :: HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112120"><span class="hs-identifier hs-var hs-var">unfoldWrapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">([TcType] -&gt; [TcType])
-&gt; (HsWrapper -&gt; [TcType]) -&gt; HsWrapper -&gt; [TcType]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112119"><span class="hs-identifier hs-var">unfWrp'</span></a></span><span>
</span><span id="line-825"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112119"><span class="annot"><span class="annottext">unfWrp' :: HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112119"><span class="hs-identifier hs-var hs-var">unfWrp'</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#WpTyApp"><span class="hs-identifier hs-type">WpTyApp</span></a></span><span> </span><span id="local-6989586621681112117"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112117"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112117"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-826"></span><span>            </span><span class="annot"><a href="#local-6989586621681112119"><span class="hs-identifier hs-var">unfWrp'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#WpCompose"><span class="hs-identifier hs-type">WpCompose</span></a></span><span> </span><span id="local-6989586621681112115"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112115"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621681112114"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112114"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112119"><span class="hs-identifier hs-var">unfWrp'</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112115"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; [TcType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112119"><span class="hs-identifier hs-var">unfWrp'</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112114"><span class="hs-identifier hs-var">w2</span></a></span><span>
</span><span id="line-827"></span><span>            </span><span class="annot"><a href="#local-6989586621681112119"><span class="hs-identifier hs-var">unfWrp'</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-828"></span><span>
</span><span id="line-829"></span><span>
</span><span id="line-830"></span><span>    </span><span class="hs-comment">-- The real work happens here, where we invoke the type checker using</span><span>
</span><span id="line-831"></span><span>    </span><span class="hs-comment">-- tcCheckHoleFit to see whether the given type fits the hole.</span><span>
</span><span id="line-832"></span><span>    </span><span class="annot"><a href="#local-6989586621681112166"><span class="hs-identifier hs-type">fitsHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- The type of the hole wrapped with the</span><span>
</span><span id="line-833"></span><span>                                    </span><span class="hs-comment">-- refinement variables created to simulate</span><span>
</span><span id="line-834"></span><span>                                    </span><span class="hs-comment">-- additional holes (if any), and the list</span><span>
</span><span id="line-835"></span><span>                                    </span><span class="hs-comment">-- of those variables (possibly empty).</span><span>
</span><span id="line-836"></span><span>                                    </span><span class="hs-comment">-- As an example: If the actual type of the</span><span>
</span><span id="line-837"></span><span>                                    </span><span class="hs-comment">-- hole (as specified by the hole</span><span>
</span><span id="line-838"></span><span>                                    </span><span class="hs-comment">-- constraint CHoleExpr passed to</span><span>
</span><span id="line-839"></span><span>                                    </span><span class="hs-comment">-- findValidHoleFits) is t and we want to</span><span>
</span><span id="line-840"></span><span>                                    </span><span class="hs-comment">-- simulate N additional holes, h_ty will</span><span>
</span><span id="line-841"></span><span>                                    </span><span class="hs-comment">-- be  r_1 -&gt; ... -&gt; r_N -&gt; t, and</span><span>
</span><span id="line-842"></span><span>                                    </span><span class="hs-comment">-- ref_vars will be [r_1, ... , r_N].</span><span>
</span><span id="line-843"></span><span>                                    </span><span class="hs-comment">-- In the base case with no additional</span><span>
</span><span id="line-844"></span><span>                                    </span><span class="hs-comment">-- holes, h_ty will just be t and ref_vars</span><span>
</span><span id="line-845"></span><span>                                    </span><span class="hs-comment">-- will be [].</span><span>
</span><span id="line-846"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-comment">-- The type we're checking to whether it can be</span><span>
</span><span id="line-847"></span><span>                       </span><span class="hs-comment">-- instantiated to the type h_ty.</span><span>
</span><span id="line-848"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- If it is not a match, we</span><span>
</span><span id="line-849"></span><span>                                                 </span><span class="hs-comment">-- return Nothing. Otherwise,</span><span>
</span><span id="line-850"></span><span>                                                 </span><span class="hs-comment">-- we Just return the list of</span><span>
</span><span id="line-851"></span><span>                                                 </span><span class="hs-comment">-- types that quantified type</span><span>
</span><span id="line-852"></span><span>                                                 </span><span class="hs-comment">-- variables in ty would take</span><span>
</span><span id="line-853"></span><span>                                                 </span><span class="hs-comment">-- if used in place of h_ty,</span><span>
</span><span id="line-854"></span><span>                                                 </span><span class="hs-comment">-- and the list types of any</span><span>
</span><span id="line-855"></span><span>                                                 </span><span class="hs-comment">-- additional holes simulated</span><span>
</span><span id="line-856"></span><span>                                                 </span><span class="hs-comment">-- with the refinement</span><span>
</span><span id="line-857"></span><span>                                                 </span><span class="hs-comment">-- variables in ref_vars.</span><span>
</span><span id="line-858"></span><span>    </span><span id="local-6989586621681112166"><span class="annot"><span class="annottext">fitsHole :: (TcType, [Id]) -&gt; TcType -&gt; TcM (Maybe ([TcType], [TcType]))
</span><a href="#local-6989586621681112166"><span class="hs-identifier hs-var hs-var">fitsHole</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112113"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112113"><span class="hs-identifier hs-var">h_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112112"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112112"><span class="hs-identifier hs-var">ref_vars</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681112111"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112111"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-859"></span><span>    </span><span class="hs-comment">-- We wrap this with the withoutUnification to avoid having side-effects</span><span>
</span><span id="line-860"></span><span>    </span><span class="hs-comment">-- beyond the check, but we rely on the side-effects when looking for</span><span>
</span><span id="line-861"></span><span>    </span><span class="hs-comment">-- refinement hole fits, so we can't wrap the side-effects deeper than this.</span><span>
</span><span id="line-862"></span><span>      </span><span class="annot"><span class="annottext">FV
-&gt; TcM (Maybe ([TcType], [TcType]))
-&gt; TcM (Maybe ([TcType], [TcType]))
forall a. FV -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Errors.Hole.html#withoutUnification"><span class="hs-identifier hs-var">withoutUnification</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112110"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (Maybe ([TcType], [TcType]))
 -&gt; TcM (Maybe ([TcType], [TcType])))
-&gt; TcM (Maybe ([TcType], [TcType]))
-&gt; TcM (Maybe ([TcType], [TcType]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-863"></span><span>      </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkingFitOf {&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112111"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-864"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112109"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112109"><span class="hs-identifier hs-var">fits</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112108"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112108"><span class="hs-identifier hs-var">wrp</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypedHole -&gt; TcType -&gt; TcType -&gt; TcM (Bool, HsWrapper)
</span><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier hs-var">tcCheckHoleFit</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112107"><span class="hs-identifier hs-var">hole</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112113"><span class="hs-identifier hs-var">h_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112111"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-865"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Did it fit?&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112109"><span class="hs-identifier hs-var">fits</span></a></span><span>
</span><span id="line-866"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wrap is: &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112108"><span class="hs-identifier hs-var">wrp</span></a></span><span>
</span><span id="line-867"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkingFitOf }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-868"></span><span>         </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112106"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112106"><span class="hs-identifier hs-var">z_wrp_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; TcM [TcType]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier hs-var">zonkTcTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper -&gt; [TcType]
</span><a href="#local-6989586621681112120"><span class="hs-identifier hs-var">unfoldWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112108"><span class="hs-identifier hs-var">wrp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-869"></span><span>         </span><span class="hs-comment">-- We'd like to avoid refinement suggestions like `id _ _` or</span><span>
</span><span id="line-870"></span><span>         </span><span class="hs-comment">-- `head _ _`, and only suggest refinements where our all phantom</span><span>
</span><span id="line-871"></span><span>         </span><span class="hs-comment">-- variables got unified during the checking. This can be disabled</span><span>
</span><span id="line-872"></span><span>         </span><span class="hs-comment">-- with the `-fabstract-refinement-hole-fits` flag.</span><span>
</span><span id="line-873"></span><span>         </span><span class="hs-comment">-- Here we do the additional handling when there are refinement</span><span>
</span><span id="line-874"></span><span>         </span><span class="hs-comment">-- variables, i.e. zonk them to read their final value to check for</span><span>
</span><span id="line-875"></span><span>         </span><span class="hs-comment">-- abstract refinements, and to report what the type of the simulated</span><span>
</span><span id="line-876"></span><span>         </span><span class="hs-comment">-- holes must be for this to be a match.</span><span>
</span><span id="line-877"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112109"><span class="hs-identifier hs-var">fits</span></a></span><span>
</span><span id="line-878"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112112"><span class="hs-identifier hs-var">ref_vars</span></a></span><span>
</span><span id="line-879"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([TcType], [TcType]) -&gt; Maybe ([TcType], [TcType])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112106"><span class="hs-identifier hs-var">z_wrp_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-880"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- To be concrete matches, matches have to</span><span>
</span><span id="line-881"></span><span>                              </span><span class="hs-comment">-- be more than just an invented type variable.</span><span>
</span><span id="line-882"></span><span>                              </span><span id="local-6989586621681112104"><span class="annot"><span class="annottext">fvSet :: VarSet
</span><a href="#local-6989586621681112104"><span class="hs-identifier hs-var hs-var">fvSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var">fvVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112110"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-883"></span><span>                              </span><span class="annot"><a href="#local-6989586621681112103"><span class="hs-identifier hs-type">notAbstract</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-884"></span><span>                              </span><span id="local-6989586621681112103"><span class="annot"><span class="annottext">notAbstract :: TcType -&gt; Bool
</span><a href="#local-6989586621681112103"><span class="hs-identifier hs-var hs-var">notAbstract</span></a></span></span><span> </span><span id="local-6989586621681112102"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112102"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe Id
</span><a href="GHC.Core.Type.html#getTyVar_maybe"><span class="hs-identifier hs-var">getTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112102"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-885"></span><span>                                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681112100"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112100"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112100"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681112104"><span class="hs-identifier hs-var">fvSet</span></a></span><span>
</span><span id="line-886"></span><span>                                                </span><span class="annot"><span class="annottext">Maybe Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-887"></span><span>                              </span><span id="local-6989586621681112097"><span class="annot"><span class="annottext">allConcrete :: Bool
</span><a href="#local-6989586621681112097"><span class="hs-identifier hs-var hs-var">allConcrete</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; Bool) -&gt; [TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="#local-6989586621681112103"><span class="hs-identifier hs-var">notAbstract</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112106"><span class="hs-identifier hs-var">z_wrp_tys</span></a></span><span>
</span><span id="line-888"></span><span>                        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112095"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112095"><span class="hs-identifier hs-var">z_vars</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM [TcType]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVars"><span class="hs-identifier hs-var">zonkTcTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112112"><span class="hs-identifier hs-var">ref_vars</span></a></span><span>
</span><span id="line-889"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112093"><span class="annot"><span class="annottext">z_mtvs :: [Id]
</span><a href="#local-6989586621681112093"><span class="hs-identifier hs-var hs-var">z_mtvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; Maybe Id) -&gt; [TcType] -&gt; [Id]
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier hs-var">mapMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe Id
</span><a href="GHC.Tc.Utils.TcType.html#tcGetTyVar_maybe"><span class="hs-identifier hs-var">tcGetTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112095"><span class="hs-identifier hs-var">z_vars</span></a></span><span>
</span><span id="line-890"></span><span>                        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112090"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112090"><span class="hs-identifier hs-var">allFilled</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool)
-&gt; TcRnIf TcGblEnv TcLclEnv Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; TcRnIf TcGblEnv TcLclEnv Bool)
-&gt; [Id] -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m Bool) -&gt; [a] -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#anyM"><span class="hs-identifier hs-var">anyM</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier hs-var">isFlexiTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112093"><span class="hs-identifier hs-var">z_mtvs</span></a></span><span>
</span><span id="line-891"></span><span>                        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112088"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112088"><span class="hs-identifier hs-var">allowAbstract</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. GeneralFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#goptM"><span class="hs-identifier hs-var">goptM</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_AbstractRefHoleFits"><span class="hs-identifier hs-var">Opt_AbstractRefHoleFits</span></a></span><span>
</span><span id="line-892"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112088"><span class="hs-identifier hs-var">allowAbstract</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112090"><span class="hs-identifier hs-var">allFilled</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681112097"><span class="hs-identifier hs-var">allConcrete</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-893"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType])))
-&gt; Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">([TcType], [TcType]) -&gt; Maybe ([TcType], [TcType])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112106"><span class="hs-identifier hs-var">z_wrp_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681112095"><span class="hs-identifier hs-var">z_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-894"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-895"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType]) -&gt; TcM (Maybe ([TcType], [TcType]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ([TcType], [TcType])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-896"></span><span>     </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112110"><span class="annot"><span class="annottext">fvs :: FV
</span><a href="#local-6989586621681112110"><span class="hs-identifier hs-var hs-var">fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; FV
</span><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-identifier hs-var">mkFVs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112112"><span class="hs-identifier hs-var">ref_vars</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-operator hs-var">`unionFV`</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112183"><span class="hs-identifier hs-var">hole_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-operator hs-var">`unionFV`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfType"><span class="hs-identifier hs-var">tyCoFVsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112111"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-897"></span><span>           </span><span id="local-6989586621681112107"><span class="annot"><span class="annottext">hole :: TypedHole
</span><a href="#local-6989586621681112107"><span class="hs-identifier hs-var hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112191"><span class="hs-identifier hs-var">typed_hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">th_hole :: Maybe Hole
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_hole"><span class="hs-identifier hs-var">th_hole</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Hole
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-898"></span><span>
</span><span id="line-899"></span><span>
</span><span id="line-900"></span><span>
</span><span id="line-901"></span><span class="hs-comment">-- | Checks whether a MetaTyVar is flexible or not.</span><span>
</span><span id="line-902"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier hs-type">isFlexiTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-903"></span><span id="isFlexiTyVar"><span class="annot"><span class="annottext">isFlexiTyVar :: Id -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier hs-var hs-var">isFlexiTyVar</span></a></span></span><span> </span><span id="local-6989586621681112086"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112086"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112086"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaDetails -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isFlexi"><span class="hs-identifier hs-var">isFlexi</span></a></span><span> </span><span class="annot"><span class="annottext">(MetaDetails -&gt; Bool)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) MetaDetails
-&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; IOEnv (Env TcGblEnv TcLclEnv) MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112086"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-904"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier hs-var">isFlexiTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-905"></span><span>
</span><span id="line-906"></span><span class="hs-comment">-- | Takes a list of free variables and restores any Flexi type variables in</span><span>
</span><span id="line-907"></span><span class="hs-comment">-- free_vars after the action is run.</span><span>
</span><span id="line-908"></span><span id="local-6989586621681112912"><span class="annot"><a href="GHC.Tc.Errors.Hole.html#withoutUnification"><span class="hs-identifier hs-type">withoutUnification</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681112912"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681112912"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-909"></span><span id="withoutUnification"><span class="annot"><span class="annottext">withoutUnification :: forall a. FV -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Errors.Hole.html#withoutUnification"><span class="hs-identifier hs-var hs-var">withoutUnification</span></a></span></span><span> </span><span id="local-6989586621681112075"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112075"><span class="hs-identifier hs-var">free_vars</span></a></span></span><span> </span><span id="local-6989586621681112074"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681112074"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-910"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112073"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112073"><span class="hs-identifier hs-var">flexis</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; TcRnIf TcGblEnv TcLclEnv Bool) -&gt; [Id] -&gt; TcM [Id]
forall (m :: * -&gt; *) a.
Applicative m =&gt;
(a -&gt; m Bool) -&gt; [a] -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#filterM"><span class="hs-identifier hs-var">filterM</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Errors.Hole.html#isFlexiTyVar"><span class="hs-identifier hs-var">isFlexiTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112072"><span class="hs-identifier hs-var">fuvs</span></a></span><span>
</span><span id="line-911"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112071"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681112071"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681112074"><span class="hs-identifier hs-var">action</span></a></span><span>
</span><span id="line-912"></span><span>          </span><span class="hs-comment">-- Reset any mutated free variables</span><span>
</span><span id="line-913"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; TcRn ()) -&gt; [Id] -&gt; TcRn ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcRn ()
</span><a href="#local-6989586621681112069"><span class="hs-identifier hs-var">restore</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681112073"><span class="hs-identifier hs-var">flexis</span></a></span><span>
</span><span id="line-914"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">a -&gt; TcM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681112071"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-915"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112069"><span class="annot"><span class="annottext">restore :: Id -&gt; TcRn ()
</span><a href="#local-6989586621681112069"><span class="hs-identifier hs-var hs-var">restore</span></a></span></span><span> </span><span id="local-6989586621681112066"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112066"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;withoutUnification: restore flexi&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112066"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-916"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcRef MetaDetails -&gt; MetaDetails -&gt; TcRn ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">writeTcRef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; TcRef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#metaTyVarRef"><span class="hs-identifier hs-var">metaTyVarRef</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681112066"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-917"></span><span>        </span><span id="local-6989586621681112072"><span class="annot"><span class="annottext">fuvs :: [Id]
</span><a href="#local-6989586621681112072"><span class="hs-identifier hs-var hs-var">fuvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; [Id]
</span><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-var">fvVarList</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621681112075"><span class="hs-identifier hs-var">free_vars</span></a></span><span>
</span><span id="line-918"></span><span>
</span><span id="line-919"></span><span class="hs-comment">-- | Reports whether first type (ty_a) subsumes the second type (ty_b),</span><span>
</span><span id="line-920"></span><span class="hs-comment">-- discarding any errors. Subsumption here means that the ty_b can fit into the</span><span>
</span><span id="line-921"></span><span class="hs-comment">-- ty_a, i.e. `tcSubsumes a b == True` if b is a subtype of a.</span><span>
</span><span id="line-922"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcSubsumes"><span class="hs-identifier hs-type">tcSubsumes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-923"></span><span id="tcSubsumes"><span class="annot"><span class="annottext">tcSubsumes :: TcType -&gt; TcType -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Errors.Hole.html#tcSubsumes"><span class="hs-identifier hs-var hs-var">tcSubsumes</span></a></span></span><span> </span><span id="local-6989586621681112061"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112061"><span class="hs-identifier hs-var">ty_a</span></a></span></span><span> </span><span id="local-6989586621681112060"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112060"><span class="hs-identifier hs-var">ty_b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, HsWrapper) -&gt; Bool
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">((Bool, HsWrapper) -&gt; Bool)
-&gt; TcM (Bool, HsWrapper) -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole -&gt; TcType -&gt; TcType -&gt; TcM (Bool, HsWrapper)
</span><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier hs-var">tcCheckHoleFit</span></a></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><a href="#local-6989586621681112059"><span class="hs-identifier hs-var">dummyHole</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112061"><span class="hs-identifier hs-var">ty_a</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112060"><span class="hs-identifier hs-var">ty_b</span></a></span><span>
</span><span id="line-924"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681112059"><span class="annot"><span class="annottext">dummyHole :: TypedHole
</span><a href="#local-6989586621681112059"><span class="hs-identifier hs-var hs-var">dummyHole</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypedHole :: Cts -&gt; [Implication] -&gt; Maybe Hole -&gt; TypedHole
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#TypedHole"><span class="hs-identifier hs-type">TypedHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">th_relevant_cts :: Cts
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_relevant_cts"><span class="hs-identifier hs-var">th_relevant_cts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span>
</span><span id="line-925"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">th_implics :: [Implication]
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_implics"><span class="hs-identifier hs-var">th_implics</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-926"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">th_hole :: Maybe Hole
</span><a href="GHC.Tc.Errors.Hole.FitTypes.html#th_hole"><span class="hs-identifier hs-var">th_hole</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Hole
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-927"></span><span>
</span><span id="line-928"></span><span class="hs-comment">-- | A tcSubsumes which takes into account relevant constraints, to fix trac</span><span>
</span><span id="line-929"></span><span class="hs-comment">-- #14273. This makes sure that when checking whether a type fits the hole,</span><span>
</span><span id="line-930"></span><span class="hs-comment">-- the type has to be subsumed by type of the hole as well as fulfill all</span><span>
</span><span id="line-931"></span><span class="hs-comment">-- constraints on the type of the hole.</span><span>
</span><span id="line-932"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier hs-type">tcCheckHoleFit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#TypedHole"><span class="hs-identifier hs-type">TypedHole</span></a></span><span>   </span><span class="hs-comment">-- ^ The hole to check against</span><span>
</span><span id="line-933"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>
</span><span id="line-934"></span><span>               </span><span class="hs-comment">-- ^ The type to check against (possibly modified, e.g. refined)</span><span>
</span><span id="line-935"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-comment">-- ^ The type to check whether fits.</span><span>
</span><span id="line-936"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-937"></span><span>               </span><span class="hs-comment">-- ^ Whether it was a match, and the wrapper from hole_ty to ty.</span><span>
</span><span id="line-938"></span><span id="tcCheckHoleFit"><span class="annot"><span class="annottext">tcCheckHoleFit :: TypedHole -&gt; TcType -&gt; TcType -&gt; TcM (Bool, HsWrapper)
</span><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier hs-var hs-var">tcCheckHoleFit</span></a></span></span><span> </span><span class="annot"><span class="annottext">TypedHole
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681112057"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112057"><span class="hs-identifier hs-var">hole_ty</span></a></span></span><span> </span><span id="local-6989586621681112056"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112056"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112057"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112056"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-939"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-940"></span><span class="annot"><a href="GHC.Tc.Errors.Hole.html#tcCheckHoleFit"><span class="hs-identifier hs-var">tcCheckHoleFit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Errors.Hole.FitTypes.html#TypedHole"><span class="hs-identifier hs-type">TypedHole</span></a></span><span> </span><span class="hs-special">{</span><span id="local-6989586621681112051"><span id="local-6989586621681112052"><span id="local-6989586621681112053"><span class="annot"><span class="annottext">[Implication]
Maybe Hole
Cts
th_hole :: Maybe Hole
th_implics :: [Implication]
th_relevant_cts :: Cts
th_hole :: TypedHole -&gt; Maybe Hole
th_implics :: TypedHole -&gt; [Implication]
th_relevant_cts :: TypedHole -&gt; Cts
</span><a href="#local-6989586621681112051"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681112050"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112050"><span class="hs-identifier hs-var">hole_ty</span></a></span></span><span> </span><span id="local-6989586621681112049"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112049"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper)
forall a. TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#discardErrs"><span class="hs-identifier hs-var">discardErrs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper))
-&gt; TcM (Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-941"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- We wrap the subtype constraint in the implications to pass along the</span><span>
</span><span id="line-942"></span><span>       </span><span class="hs-comment">-- givens, and so we must ensure that any nested implications and skolems</span><span>
</span><span id="line-943"></span><span>       </span><span class="hs-comment">-- end up with the correct level. The implications are ordered so that</span><span>
</span><span id="line-944"></span><span>       </span><span class="hs-comment">-- the innermost (the one with the highest level) is first, so it</span><span>
</span><span id="line-945"></span><span>       </span><span class="hs-comment">-- suffices to get the level of the first one (or the current level, if</span><span>
</span><span id="line-946"></span><span>       </span><span class="hs-comment">-- there are no implications involved).</span><span>
</span><span id="line-947"></span><span>       </span><span id="local-6989586621681112047"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681112047"><span class="hs-identifier hs-var">innermost_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681112052"><span class="hs-identifier hs-var">th_implics</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-948"></span><span>                          </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-949"></span><span>                          </span><span class="hs-comment">-- imp is the innermost implication</span><span>
</span><span id="line-950"></span><span>                          </span><span class="hs-special">(</span><span id="local-6989586621681112045"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681112045"><span class="hs-identifier hs-var">imp</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[Implication]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcLevel
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var hs-var">ic_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681112045"><span class="hs-identifier hs-var">imp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-951"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681112043"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112043"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681112042"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112042"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; TcM (HsWrapper, WantedConstraints)
-&gt; TcM (HsWrapper, WantedConstraints)
forall a. TcLevel -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#setTcLevel"><span class="hs-identifier hs-var">setTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681112047"><span class="hs-identifier hs-var">innermost_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (HsWrapper, WantedConstraints)
 -&gt; TcM (HsWrapper, WantedConstraints))
-&gt; TcM (HsWrapper, WantedConstraints)
-&gt; TcM (HsWrapper, WantedConstraints)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcM HsWrapper -&gt; TcM (HsWrapper, WantedConstraints)
forall a. TcM a -&gt; TcM (a, WantedConstraints)
</span><a href="GHC.Tc.Utils.Monad.html#captureConstraints"><span class="hs-identifier hs-var">captureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM HsWrapper -&gt; TcM (HsWrapper, WantedConstraints))
-&gt; TcM HsWrapper -&gt; TcM (HsWrapper, WantedConstraints)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-952"></span><span>                         </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier hs-var">tcSubTypeSigma</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#ExprSigCtxt"><span class="hs-identifier hs-var">ExprSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112049"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681112050"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>
</span><span id="line-953"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Checking hole fit {&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-954"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wanteds are: &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112042"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-955"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112042"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681112053"><span class="hs-identifier hs-var">th_relevant_cts</span></a></span><span>
</span><span id="line-956"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;}&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-957"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112043"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-958"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681112036"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681112036"><span class="hs-identifier hs-var">fresh_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">newTcEvBinds</span></a></span><span>
</span><span id="line-959"></span><span>                </span><span class="hs-comment">-- The relevant constraints may contain HoleDests, so we must</span><span>
</span><span id="line-960"></span><span>                </span><span class="hs-comment">-- take care to clone them as well (to avoid #15370).</span><span>
</span><span id="line-961"></span><span>               </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112034"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681112034"><span class="hs-identifier hs-var">cloned_relevants</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) Ct)
-&gt; Cts -&gt; IOEnv (Env TcGblEnv TcLclEnv) Cts
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) Ct
</span><a href="GHC.Tc.Utils.TcMType.html#cloneWanted"><span class="hs-identifier hs-var">cloneWanted</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681112053"><span class="hs-identifier hs-var">th_relevant_cts</span></a></span><span>
</span><span id="line-962"></span><span>                 </span><span class="hs-comment">-- We wrap the WC in the nested implications, see</span><span>
</span><span id="line-963"></span><span>                 </span><span class="hs-comment">-- Note [Checking hole fits]</span><span>
</span><span id="line-964"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681112031"><span class="annot"><span class="annottext">outermost_first :: [Implication]
</span><a href="#local-6989586621681112031"><span class="hs-identifier hs-var hs-var">outermost_first</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Implication] -&gt; [Implication]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681112052"><span class="hs-identifier hs-var">th_implics</span></a></span><span>
</span><span id="line-965"></span><span>                    </span><span class="hs-comment">-- We add the cloned relevants to the wanteds generated by</span><span>
</span><span id="line-966"></span><span>                    </span><span class="hs-comment">-- the call to tcSubType_NC, see Note [Relevant constraints]</span><span>
</span><span id="line-967"></span><span>                    </span><span class="hs-comment">-- There's no need to clone the wanteds, because they are</span><span>
</span><span id="line-968"></span><span>                    </span><span class="hs-comment">-- freshly generated by `tcSubtype_NC`.</span><span>
</span><span id="line-969"></span><span>                     </span><span id="local-6989586621681112030"><span class="annot"><span class="annottext">w_rel_cts :: WantedConstraints
</span><a href="#local-6989586621681112030"><span class="hs-identifier hs-var hs-var">w_rel_cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Cts -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#addSimples"><span class="hs-identifier hs-var">addSimples</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112042"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681112034"><span class="hs-identifier hs-var">cloned_relevants</span></a></span><span>
</span><span id="line-970"></span><span>                     </span><span id="local-6989586621681112027"><span class="annot"><span class="annottext">final_wc :: WantedConstraints
</span><a href="#local-6989586621681112027"><span class="hs-identifier hs-var hs-var">final_wc</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; WantedConstraints -&gt; WantedConstraints)
-&gt; WantedConstraints -&gt; [Implication] -&gt; WantedConstraints
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EvBindsVar -&gt; Implication -&gt; WantedConstraints -&gt; WantedConstraints
</span><a href="#local-6989586621681112025"><span class="hs-identifier hs-var">setWCAndBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681112036"><span class="hs-identifier hs-var">fresh_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112030"><span class="hs-identifier hs-var">w_rel_cts</span></a></span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681112031"><span class="hs-identifier hs-var">outermost_first</span></a></span><span>
</span><span id="line-971"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;final_wc is: &quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112027"><span class="hs-identifier hs-var">final_wc</span></a></span><span>
</span><span id="line-972"></span><span>               </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681112024"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112024"><span class="hs-identifier hs-var">rem</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcM WantedConstraints
forall a. TcS a -&gt; TcM a
</span><a href="GHC.Tc.Solver.Monad.html#runTcSDeriveds"><span class="hs-identifier hs-var">runTcSDeriveds</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints -&gt; TcM WantedConstraints)
-&gt; TcS WantedConstraints -&gt; TcM WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier hs-var">simpl_top</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112027"><span class="hs-identifier hs-var">final_wc</span></a></span><span>
</span><span id="line-973"></span><span>               </span><span class="hs-comment">-- We don't want any insoluble or simple constraints left, but</span><span>
</span><span id="line-974"></span><span>               </span><span class="hs-comment">-- solved implications are ok (and necessary for e.g. undefined)</span><span>
</span><span id="line-975"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rems was:&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112024"><span class="hs-identifier hs-var">rem</span></a></span><span>
</span><span id="line-976"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;}&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-977"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, HsWrapper) -&gt; TcM (Bool, HsWrapper)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isSolvedWC"><span class="hs-identifier hs-var">isSolvedWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112024"><span class="hs-identifier hs-var">rem</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681112043"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-978"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-979"></span><span>       </span><span class="annot"><a href="#local-6989586621681112025"><span class="hs-identifier hs-type">setWCAndBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBindsVar"><span class="hs-identifier hs-type">EvBindsVar</span></a></span><span>         </span><span class="hs-comment">-- Fresh ev binds var.</span><span>
</span><span id="line-980"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>        </span><span class="hs-comment">-- The implication to put WC in.</span><span>
</span><span id="line-981"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>  </span><span class="hs-comment">-- The WC constraints to put implic.</span><span>
</span><span id="line-982"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>  </span><span class="hs-comment">-- The new constraints.</span><span>
</span><span id="line-983"></span><span>       </span><span id="local-6989586621681112025"><span class="annot"><span class="annottext">setWCAndBinds :: EvBindsVar -&gt; Implication -&gt; WantedConstraints -&gt; WantedConstraints
</span><a href="#local-6989586621681112025"><span class="hs-identifier hs-var hs-var">setWCAndBinds</span></a></span></span><span> </span><span id="local-6989586621681112022"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681112022"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681112021"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681112021"><span class="hs-identifier hs-var">imp</span></a></span></span><span> </span><span id="local-6989586621681112020"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112020"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-984"></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkImplicWC"><span class="hs-identifier hs-var">mkImplicWC</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag Implication -&gt; WantedConstraints)
-&gt; Bag Implication -&gt; WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Bag Implication
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; Bag Implication) -&gt; Implication -&gt; Bag Implication
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681112021"><span class="hs-identifier hs-var">imp</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681112020"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681112022"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-985"></span></pre></body></html>